Solved

Can some one decode what these regex do?

Posted on 2006-07-22
9
242 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
ID: 17161560
"\\$\\{([\\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
ID: 17162023
I think, it is

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

Assisted Solution

by:ksivananth
ksivananth earned 166 total points
ID: 17162034
for e.g.,

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

it matches,

${hello.123.fine}
${hello1233...}
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 26

Expert Comment

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

Assisted Solution

by:CEHJ
CEHJ earned 166 total points
ID: 17162434
>>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
ID: 17162457
>>Of course the regex will also match the empty var:

true
0
 
LVL 37

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse compiler vs Installed JREs option 3 75
compre toata in where clue oracle 4 55
Way to decrease size of apk file 9 42
servlet filter example 37 37
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.

919 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

21 Experts available now in Live!

Get 1:1 Help Now