Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a balanced capture between two character types?

Asked by 8 years ago

Lets say I want to make a balanced capture between the occurrence of an uppercase an a lowercase letter.

words = "I WANT 9()?!., CHOCOLATE milk!"

using the balanced capture, %bxy, how would I match a pattern to correspond to the the the first occurrence of an uppercase letter, followed by a lowercase letter and everything inbetween?

My ideal solution does not work

for match in string.gmatch(words, "%b%u%l") do
    print (match)
    wait(.1)
end
0
Ideally it should print "I WANT 9()?!., CHOCOLATE m" randomsmileyface 375 — 8y
0
I don't understand what you're asking. Can you give examples (what should match, what shouldn't)? BlueTaslem 18071 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

I believe the pattern you're looking for is "%u%L*%l". That's one upper case letter followed by non-lowercase letters followed by a single lower case letter.

(I don't think "balanced captures" have anything to do with it.)

Ad

Answer this question