?
Solved

Can some one decode what these regex do?

Posted on 2006-07-22
9
Medium Priority
?
277 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
[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
  • 4
  • 2
9 Comments
 
LVL 37

Accepted Solution

by:
Harisha M G earned 672 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 664 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 664 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

770 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