• 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

Java Regex

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,

I am new at regex and I have read several tutorials but I still can't find my answer, which is, is there a way to parse using 2 different patterns?

For example,


Sorry for being vague. To explain it in sentences, I am parsing source (.*cpp) files and I am trying to find the following:



Sounds easy, however, some source files have it like the following:



Is there anyway that I could search on two patterns?

Thank you for any help.
 
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
You can build a pattern from 2 patterns using the logical OR operator.

X|Y means match either X or Y, and if you use groups...

"(some regular expression)|(another regular expression)" will match either expression.

Henry
 
Vincent Tomas
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My gosh. How did I missed that? Thanks Henry!
 
reply
    Bookmark Topic Watch Topic
  • New Topic