Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

2 comments

0

Ideally it should print "I WANT 9()?!., CHOCOLATE m"

0

I don't understand what you're asking. Can you give examples (what should match, what shouldn't)?

1 answer

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.)

This discussion is preserved as it was. New answers, comments, and votes are closed.