Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
39
Task/Regular-expressions/MAXScript/regular-expressions.max
Normal file
39
Task/Regular-expressions/MAXScript/regular-expressions.max
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
samples = #("Some string 123","Example text 123","string",\
|
||||
"ThisString Will Not Match","A123,333,string","123451")
|
||||
samples2 = #("I am a string","Me too.")
|
||||
|
||||
regex = dotnetobject "System.Text.RegularExpressions.Regex" ".*\bstring*"
|
||||
regex2 = dotnetobject "System.Text.RegularExpressions.Regex" "\ba\b"
|
||||
|
||||
clearlistener()
|
||||
|
||||
format "Pattern is : %\n" (regex.toString())
|
||||
|
||||
for i in samples do
|
||||
(
|
||||
if regex.ismatch(i) then
|
||||
(
|
||||
format "The string \"%\" matches the pattern\n" i
|
||||
)
|
||||
else
|
||||
(
|
||||
format "The string \"%\" doesn't match the pattern\n" i
|
||||
)
|
||||
)
|
||||
|
||||
-- replacement
|
||||
|
||||
format "Pattern is : %\n" (regex2.toString())
|
||||
|
||||
for i in samples2 do
|
||||
(
|
||||
if regex2.ismatch(i) then
|
||||
(
|
||||
local replaced = regex2.replace i "another"
|
||||
format "The string \"%\" matched the pattern, so it was replaced: \"%\"\n" i replaced
|
||||
)
|
||||
else
|
||||
(
|
||||
format "The string \"%\" does not match the pattern\n" i
|
||||
)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue