# Regular Expressions for Range Statements

• 04-01-2014, 06:00 PM
pavan528
Regular Expressions for Range Statements
Hi all,
I have the following Output
_G7120+1#=K,
_G7132+_G7133#=_G7120,
_G7144+_G7145#=_G7132,
_G7156+_G7157#=_G7144,
_G7168*Z#=_G7156,
_G7180*Z#=_G7168,
_G7192*Z#=_G7180,
_G7204*Y#=_G7192,
_G7192, in 10..15 \/ 16
X*Y#=_G7204,
X+Y#=_G7133,
_G7145+X#=Z1_a,
Y in 1..15,
Z/Y#=_G7157,
__X in 1..15 \/ 17 \/ 20.

From this, I need to extract the statements of variables that do not start with _G . I mean, I need to extract, Y in 1..15 , __X in 1..15 \/17\/20 but not _G7145 in 10..15 \/ 16.

I am using regular Expression for this as [^_G]^[A-Za-z0-9_]+ in|ins [-9 -9]..[-9-9] [\/[-9-9]..[-9-9]]+

Can someone kindly confirm if it is right or if not correct it?

Thanks,
• 04-01-2014, 08:02 PM
jashburn
Re: Regular Expressions for Range Statements
I'm wondering what's stopping you from using just String.contains(s) and String.startsWith(prefix)? E.g., if line refers to a line of text,
Code:

`if (line.contains(" in ") && !line.startsWith("_G"))`
should match only Y in 1..15 and __X in 1..15 \/17\/20

Keep it simple, I'm thinking...
• 04-01-2014, 09:24 PM
jim829
Re: Regular Expressions for Range Statements
Anytime there is an underscore in the last statement of your code snippet it won't show up. So place an empty comment after it (e.g. //). It's
another problem with the formatter.

Regards,
Jim