Need regular expression to test

I need a regular expression that will match on the following conditions:
1. Needs to match any string that contains “Application1 myCompany M117 Corp_LA”
2. Needs to match any string that contains “Application2 myCompany M117 Corp_LA”
3. Needs to match any string that contains “Application3 myCompany M117 Corp_LA”
4. Needs to match any string that starts with an underscore. For example _app1 or _app_2, but NOT app_3

I’ve tried:
(Application1 myCompany M117|Application2 myCompany M117 Corp_LA|Application3 myCompany M117 Corp_LA)|^(_.*)

This seems to work in an online regex tester, but doesn’t work in the actual application.
Christopher ScheneSystem Engineer/Software EngineerAsked:
Who is Participating?
 
AmickConnect With a Mentor Commented:
One more modification:

Boost documentation says:
The escape sequence \R matches any line ending character sequence, specifically it is identical to the expression (?>\x0D\x0A?|[\x0A-\x0C\x85\x{2028}\x{2029}]).

To take advantage of that use:

Application[1-3] myCompany M117 Corp_LA|\R_.*|^_.*
0
 
ozoCommented:
What application, and how is it used in the actual application?
0
 
Christopher ScheneSystem Engineer/Software EngineerAuthor Commented:
It is actually a home grown internal application......but the app is using boost RegEx
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
AmickConnect With a Mentor Commented:
Application[1-3] myCompany M117 Corp_LA|^_.*

Activate multi-line mode and remember that spacing matters.
0
 
ozoCommented:
Do you know exactly what parameters are being passed to the boost RegEx function?
0
 
AmickCommented:
Lacking a multi-line mode you might also try

Application[1-3] myCompany M117 Corp_LA|\n_.*

OR

Application[1-3] myCompany M117 Corp_LA|\r_.*
0
 
käµfm³d 👽Commented:
@Amick

You may want to adjust your last offering since it wouldn't account for the first line starting with an underscore  ; )
0
 
AmickCommented:
@kaufmed - Excellent point!

I had my eye on those cases where multi-line mode might be necessary and not available, but clearly the unique first-line case can be addressed by appending the original |^_.* as in:

Application[1-3] myCompany M117 Corp_LA|\r_.*|^_.*
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.