Solved

Need regular expression to test

Posted on 2012-03-12
8
277 Views
Last Modified: 2012-03-16
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.
0
Comment
Question by:Christopher Schene
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 37712384
What application, and how is it used in the actual application?
0
 

Author Comment

by:Christopher Schene
ID: 37712443
It is actually a home grown internal application......but the app is using boost RegEx
0
 
LVL 12

Assisted Solution

by:Amick
Amick earned 500 total points
ID: 37712464
Application[1-3] myCompany M117 Corp_LA|^_.*

Activate multi-line mode and remember that spacing matters.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 84

Expert Comment

by:ozo
ID: 37712503
Do you know exactly what parameters are being passed to the boost RegEx function?
0
 
LVL 12

Expert Comment

by:Amick
ID: 37712504
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
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37712545
@Amick

You may want to adjust your last offering since it wouldn't account for the first line starting with an underscore  ; )
0
 
LVL 12

Expert Comment

by:Amick
ID: 37712582
@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
 
LVL 12

Accepted Solution

by:
Amick earned 500 total points
ID: 37715575
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

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question