Christopher Schene
asked on
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.
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.
What application, and how is it used in the actual application?
ASKER
It is actually a home grown internal application......but the app is using boost RegEx
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you know exactly what parameters are being passed to the boost RegEx function?
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_.*
Application[1-3] myCompany M117 Corp_LA|\n_.*
OR
Application[1-3] myCompany M117 Corp_LA|\r_.*
@Amick
You may want to adjust your last offering since it wouldn't account for the first line starting with an underscore ; )
You may want to adjust your last offering since it wouldn't account for the first line starting with an underscore ; )
@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_.*|^_.*
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_.*|^_.*
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.