menu
Roblox Forum Archive
Home
User Search
Forums
Donate
search
settings
Home
User Search
Forums
Donate
launch
Go to User Dashboard
Forums
Scripters
Help with gsub and string patterns
chevron_left
chevron_left
chevron_left
of
1
chevron_right
chevron_right
chevron_right
Help with gsub and string patterns
doggyjoe9
Join Date: 2010-01-25
Post Count: 8
#184952456
Monday, March 07, 2016 11:38 PM GMT
Is there some sort of string pattern I can use to find, say, the 7th letter in a string?
Go to point in time
arrow_right
10 minutes before
5 minutes before
At time of posting
5 minutes after
10 minutes after
more_horiz
doggyjoe9
Join Date: 2010-01-25
Post Count: 8
#184952538
Monday, March 07, 2016 11:39 PM GMT
And replace it*
Go to point in time
arrow_right
10 minutes before
5 minutes before
At time of posting
5 minutes after
10 minutes after
more_horiz
eLunate
Join Date: 2014-07-29
Post Count: 13268
#184953404
Monday, March 07, 2016 11:52 PM GMT
TargetString:sub(7,7) -> 7th letter
Go to point in time
arrow_right
10 minutes before
5 minutes before
At time of posting
5 minutes after
10 minutes after
more_horiz
doggyjoe9
Join Date: 2010-01-25
Post Count: 8
#184955957
Tuesday, March 08, 2016 12:29 AM GMT
But how would I REPLACE the seventh letter of the string?
Go to point in time
arrow_right
10 minutes before
5 minutes before
At time of posting
5 minutes after
10 minutes after
more_horiz
TheScripterGeek
Join Date: 2012-09-02
Post Count: 1192
#184956877
Tuesday, March 08, 2016 12:41 AM GMT
string = string:sub(7,7)
Go to point in time
arrow_right
10 minutes before
5 minutes before
At time of posting
5 minutes after
10 minutes after
more_horiz
benthanh123
Join Date: 2010-05-27
Post Count: 567
#184960413
Tuesday, March 08, 2016 1:32 AM GMT
string.gsub(strings, "(%w%w%w%w%w%w)(%w)(%w*)", "%1[[change here]]%3")--remove [[]]
Go to point in time
arrow_right
10 minutes before
5 minutes before
At time of posting
5 minutes after
10 minutes after
more_horiz
cntkillme
Join Date: 2008-04-07
Post Count: 49450
#184964240
Tuesday, March 08, 2016 2:28 AM GMT
......(.), blah It's still gross, I'd probably use string.sub twice and concatenate them all together.
Go to point in time
arrow_right
10 minutes before
5 minutes before
At time of posting
5 minutes after
10 minutes after
more_horiz
Froast
Join Date: 2009-03-12
Post Count: 3134
#184964370
Tuesday, March 08, 2016 2:30 AM GMT
ROBLOX's filter doing great as usual and blocked my post so I've put it here: pastebin.com/u8haB4P
Go to point in time
arrow_right
10 minutes before
5 minutes before
At time of posting
5 minutes after
10 minutes after
more_horiz
eLunate
Join Date: 2014-07-29
Post Count: 13268
#184991368
Tuesday, March 08, 2016 7:28 PM GMT
Technically, it's more like function replace(s,n,r) return s:gsub("("..string.rep('.',n-1)..").","%1"..r); end
Go to point in time
arrow_right
10 minutes before
5 minutes before
At time of posting
5 minutes after
10 minutes after
more_horiz
chevron_left
chevron_left
chevron_left
of
1
chevron_right
chevron_right
chevron_right