Last active
December 27, 2015 17:39
-
-
Save wbailey/7363555 to your computer and use it in GitHub Desktop.
simple regex for jason
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.9.3-p392 :026 > s | |
=> "DB2:/XMETA/NODE0000/DB2LOG" | |
1.9.3-p392 :028 > /^([^\/]*\/[^\/]*\/).*$/.match(s) | |
=> #<MatchData "DB2:/XMETA/NODE0000/DB2LOG" 1:"DB2:/XMETA/"> | |
1.9.3-p392 :030 > /^([^\/]*\/[^\/]*)\/.*$/.match(s) | |
=> #<MatchData "DB2:/XMETA/NODE0000/DB2LOG" 1:"DB2:/XMETA"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'll break the regex (contained in line 3 from / ... /) by parts
6 .* - match and ignore remaining characters
8 $ - end of string delimeter
The match data just shows the full string and the corresponding text you want to match. If you want to eliminate the trailing slash, then just move the paren to the position in line 5.