• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RegEx pattern

 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
RegEx pattern for these Strings - one.two.three (or) onew.twos.trhhee.sdfour (or) fsdf.abcdr.trew.jffgh.qacd

This does not work  ((?:[a-z][a-z]+))
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Regular expression is more than just a pattern. How are you using it? find()? matches()? split()? replaceAll()? etc. etc. etc.

Perhaps you can elaborate a bit?

Henry
 
Greenhorn
Posts: 4
2
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you need something like this i suppose:
([a-z][.a-z]+)
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you describe in words what you want to match? Is it "a sequence of lowercase letters, interspersed by dots, with at least one letter between dots"? If so, the dot should appear somewhere in the pattern (keeping in mind that a dot is a special pattern, and thus needs to be escaped to match a literal dot).
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
an example is terrific, but it is not a spec. This regex will work for your example, but it's almost without a doubt not what you want:

one\.two\.three|onew\.twos\.trhhee\.sdfour|fsdf\.abcdr\.trew\.jffgh.qacd

without a spec, you can't tell me the above is NOT what you want.
 
reply
    Bookmark Topic Watch Topic
  • New Topic