3 ms·
What about using this pattern matching visualisation with SNOBOL? I'd suggest it could be better for this than RegEx. http://langexplr.blogspot.co.uk/2007/12/q
by ZenoArrow 10y ago
What about using this pattern matching visualisation with SNOBOL? I'd suggest it could be better for this than RegEx.
http://langexplr.blogspot.co.uk/2007/12/quick-look-at-snobol.html?m=1 http://langexplr.blogspot.co.uk/2007/12/quick-look-at-snobol...
"The most interesting thing about the language is the string pattern matching capabilities. Here's an small(and very incomplete) example that extracts the parts of a simplified URL string:
LETTER = "abcdefghijklmnopqrstuvwxyz"
LETTERORDOT = "." LETTER
LETTERORSLASH = "/" LETTER
LINE = INPUT
LINE SPAN(LETTER) . PROTO "://" SPAN(LETTERORDOT) . HOST "/" SPAN(LETTERORSLASH) . RES
OUTPUT = PROTO
OUTPUT = HOST
OUTPUT = RES
END
In line 6, the contents of the LINE variable is matched against a pattern. The pattern contains the following elements:
1.The SPAN(LETTER) . PROTO "://" section says identify a sequence of letters followed by "://" and assign them to the variable called PROTO
2.The SPAN(LETTERORDOT) . HOST "/" secotion says take a sequence of letters and dots followed by "/" and assign then to the variable called HOST
3.Finally the last section takes the remaining letters and slash characters and assign them to the RES variable"