• Post Reply Bookmark Topic Watch Topic
  • New Topic

Could you please explain me the meaning of this RegEx?  RSS feed

 
Greenhorn
Posts: 16
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Could you please anyone explain the meaning of the following RegEx?
"^(VSN\\p{Graph}+):([0-9]{7,15})$"



Thanks a ton in advance...

 
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you first tell us your interpretation of it? This page could help.

edit Ravi, you seem to have a history of not returning to the threads you start. You might like to go through this page.
 
Ravi Vanamala
Greenhorn
Posts: 16
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its my bad, will change it. :( regrets.
I might have posted and logged out due to reasons and might not logged in for a long or forgot, meanwhile I might got the answer.
Quite away from Java and back to Java after a while. So, you can see very less posts...From now I would be regularly be part of it.
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, did you have a look at the documentation, and do you now understand what the regex means? Is there something specific about the regex that you don't understand?
 
Ravi Vanamala
Greenhorn
Posts: 16
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an basic idea of regular expressions... but here I got this regex from someone (not a techie), to parse/write a parser it in Java.
I could not make complete meaning...So I was looking for help to understand of this pattern.

I was assuming the meaning...

^ ----> starting of the regex pattern

$ ----> ending of the regex pattern

(VSN\\p{Graph}+) -----> V or S or N or VSN any combination followed by a "visible character" (to avoid the SPACE or TAB) occurs ONE or MORE times

([0-9]{7,15}) ----> digits - between 0 and 9 with atleast minimum of 7 digits and maximum of 15 digits can be allowed.

: -----> Don't know about it. --------> is that the same as OR symbol?? or something else?? Including this what is the complete meaning of the above regex?

Could you please explain the complete meaning of it? if you see anything missing and its required modification in the above format...please correct it and do let me know
the same.

Thanks a ton in advance...
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not far off.

'^' means the start of the string you're matching, and '$' is the end of it. So including those means that the regular expression has to match the entire string, not just part of it.

The 'VSN' bit means just that - no 'or' involved. The ':' is also just what it says - a colon.

So this should match:
'VSN', followed by at least one visible character, followed by a colon, followed by 7-15 digits.

E.g. "VSNiydfglaksdhfbv:87654321"

The brackets don't affect what the expression will match, but they let you extract parts of the string once a match has been found.
 
Ravi Vanamala
Greenhorn
Posts: 16
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks you so much Matthew Brown, Darryl Burke and Jesper de Jong
Thanks a lot for your help, quickly.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!