Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
replacerx multiple matches in callback
#1
Anyway to have a REPLACERX callback function that handles matching multiple matches?

for example:
Code:
Copy      Help
str s="HELLO WORLD ~ hello world"
s.replacerx("(.+) ~ (.+)" "$2 ~ $1")
out s

So in the example, handle that switch of the matches in a function?
#2
I sort of figured it out.

Code:
Copy      Help
function# REPLACERXCB&x

str s1.get(x.match x.vec[1].cpMin x.vec[1].cpMax)
str s2.get(x.match x.vec[2].cpMin x.vec[2].cpMax)

x.match=F"{s1.lcase} ~ {s2.ucase}"
#3
yes, using x.vec
#4
str s1.get(x.subject x.vec[1].cpMin (x.vec[1].cpMax-x.vec[1].cpMin))
str s2.get(x.subject x.vec[2].cpMin (x.vec[2].cpMax-x.vec[2].cpMin))


Forum Jump:


Users browsing this thread: 1 Guest(s)