Results 1 to 3 of 3
- 04-01-2014, 07:00 PM #1
Member
- Join Date
- Sep 2012
- Posts
- 13
- Rep Power
- 0
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, 09:02 PM #2
Senior Member
- Join Date
- Feb 2014
- Posts
- 219
- Rep Power
- 8
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,
Java Code:if (line.contains(" in ") && !line.startsWith("_G"))
Keep it simple, I'm thinking...
- 04-01-2014, 10:24 PM #3
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
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,
JimThe JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
Similar Threads
-
Regular expressions
By freelancer in forum New To JavaReplies: 1Last Post: 11-25-2011, 01:41 PM -
Regular Expressions Help
By Death Sickle in forum New To JavaReplies: 4Last Post: 04-04-2011, 05:21 AM -
Regular Expressions for certain format
By mohammedelbes in forum Advanced JavaReplies: 3Last Post: 01-06-2011, 07:00 PM -
regular expressions
By sozeee in forum New To JavaReplies: 3Last Post: 12-06-2010, 10:58 PM -
Regular Expressions in java
By blue404 in forum Advanced JavaReplies: 2Last Post: 09-26-2008, 04:43 AM
Bookmarks