generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: String Manipulation

Previous Thread :: Next Thread 
KB97 is not online. KB97
Joined: 01 Jul 2009
Total Posts: 683
07 Nov 2011 04:57 PM
Using gmatch, I'm trying to 'split' a string into its individual words, keep the symbol prefixes, and words contained in brackets are kept as a whole, so that this string:

"/slash word @symbol [multiple word input] #[with symbol]"

Would result in these captures:

/slash
word
@symbol
[multiple word input]
#[with symbol]

I have some experience with string manipulation, but I haven't found a way to do this.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
07 Nov 2011 04:58 PM
for word in STRING:gmatch("%a+") do
print(Word)
end
Report Abuse
KB97 is not online. KB97
Joined: 01 Jul 2009
Total Posts: 683
07 Nov 2011 05:00 PM
"... and words contained in brackets are kept as a whole ..."
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
07 Nov 2011 05:00 PM
Oops.

for word in STRING:gmatch("%p%a+") do
print(word)
end
Report Abuse
KB97 is not online. KB97
Joined: 01 Jul 2009
Total Posts: 683
07 Nov 2011 05:54 PM
Thanks for trying, but that's not what I need. Read the whole post.
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
07 Nov 2011 05:56 PM
Um.... Try separating them using %s.

I'm not that good with strings.
Report Abuse
KB97 is not online. KB97
Joined: 01 Jul 2009
Total Posts: 683
07 Nov 2011 06:34 PM
Bump.
Report Abuse
KB97 is not online. KB97
Joined: 01 Jul 2009
Total Posts: 683
07 Nov 2011 07:21 PM
Bump again.
Report Abuse
KB97 is not online. KB97
Joined: 01 Jul 2009
Total Posts: 683
07 Nov 2011 08:16 PM
Bump again again.
Report Abuse
KB97 is not online. KB97
Joined: 01 Jul 2009
Total Posts: 683
07 Nov 2011 09:27 PM
Ditto.
Report Abuse
KB97 is not online. KB97
Joined: 01 Jul 2009
Total Posts: 683
07 Nov 2011 10:32 PM
Last bump for today...
Report Abuse
RistoReipas is not online. RistoReipas
Joined: 07 May 2009
Total Posts: 93
07 Nov 2011 11:50 PM
Its not gmatch, but here it goes...

s = "/slash word @symbol [multiple word input] #[with symbol]"

pattern = "(%p%a+)%s(%a+)%s(%p%a+)%s(%p.-%p)%s(%p%p.-%p)"

Start, End, First, Second, Third, Fourth, Fifth = string.find( s, pattern )
print(First)
print(Second)
print(Third)
print(Fourth)
print(Fifth)
Report Abuse
KB97 is not online. KB97
Joined: 01 Jul 2009
Total Posts: 683
08 Nov 2011 03:18 PM
Thanks, but that isn't what I need.

The string being 'split' is a chat message, and the words and positions of brackets and symbols are just for testing purposes. They won't be consistent in length, position or context in actual use.
Report Abuse
KB97 is not online. KB97
Joined: 01 Jul 2009
Total Posts: 683
08 Nov 2011 04:53 PM
Last bump.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image