Solved

Can some one decode what these regex do?

Posted on 2006-07-22
9
233 Views
Last Modified: 2010-03-31
I am debugging a piece of code and have a following scenario

private String REGEXP_VARIABLE_EXPANSION = "\\$\\{([\\w\\.?]*)\\}";

// How we test for booleans
private String REGEXP_BOOLEAN_VALUE = "True|T|Yes|Y";

If someone can give me an example string that will be great.  I know reverse engineering is crazy but what to do?

I am not a regex person.  But I have to work with a code.

Thanx in advance

slick

0
Comment
Question by:slickdeals
  • 4
  • 2
9 Comments
 
LVL 37

Accepted Solution

by:
Harisha M G earned 168 total points
Comment Utility
"\\$\\{([\\w\\.?]*)\\}"

By de-escaping (?) it, the regex becomes:

\$\{([\w\.?]*)\}

So, it matches any string that has initially a $ sign, then { and a character, then any no of characters, again }

For ex,

${hello}

would match, but

${ hello}, ${.hello} etc won't match.


And the second one matches only True, T, Yes or Y
0
 
LVL 26

Expert Comment

by:ksivananth
Comment Utility
I think, it is

${Combination of alpha numeric chars with dots}
0
 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 166 total points
Comment Utility
for e.g.,

"${hello.123.fine} Some Text ${hello1233...} Some more here ${Not Matches.}"

it matches,

${hello.123.fine}
${hello1233...}
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 26

Expert Comment

by:ksivananth
Comment Utility
I feel, the "?" in the regex is irrelevant
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 166 total points
Comment Utility
>>I feel, the "?" in the regex is irrelevant

True. Of course the regex will also match the empty var:

${}

The other one should probably be named

REGEXP_BOOLEAN_VALUE_TRUE

0
 
LVL 26

Expert Comment

by:ksivananth
Comment Utility
>>Of course the regex will also match the empty var:

true
0
 
LVL 37

Expert Comment

by:Harisha M G
Comment Utility
${.hello} matches.. I was thinking of something else..
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now