Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Regex to find an alphanumeric sequence in a block of text.

Regex to find an alphanumeric sequence in a block of text.

Scheduled Pinned Locked Moved Java
regextutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kartikdasani
    wrote on last edited by
    #1

    I need to find an alphanumeric sequence example:1wer3rtyu4sd inside a block of text to which the alpanumeric sequence is unique. I am using the following piece of code: Pattern pattern = Pattern.compile(regex);//need a proper regex Matcher matcher = pattern.matcher(strLine); //strLine consists the text if (matcher.find()) { System.out.println(matcher.group()); System.out.println(matcher.groupCount()); }

    P 1 Reply Last reply
    0
    • K kartikdasani

      I need to find an alphanumeric sequence example:1wer3rtyu4sd inside a block of text to which the alpanumeric sequence is unique. I am using the following piece of code: Pattern pattern = Pattern.compile(regex);//need a proper regex Matcher matcher = pattern.matcher(strLine); //strLine consists the text if (matcher.find()) { System.out.println(matcher.group()); System.out.println(matcher.groupCount()); }

      P Offline
      P Offline
      Peter_in_2780
      wrote on last edited by
      #2

      Your question is unclear. Are you searching for a pattern that you already know exactly? If so, use strLine.indexOf(wantedString). If you are doing something selse, you need to tell us more about how to specify the search pattern. Peter

      Software rusts. Simon Stephenson, ca 1994.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups