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 patterns

Previous Thread :: Next Thread 
xolbStudios is not online. xolbStudios
Joined: 05 Nov 2009
Total Posts: 504
06 Nov 2014 01:43 PM
How do I find certain text before a character in a message?
I'm still a beginner in lua so I'm not very familiar with string.
Report Abuse
xolbStudios is not online. xolbStudios
Joined: 05 Nov 2009
Total Posts: 504
06 Nov 2014 01:44 PM
**I'm still mediocre in Lua.
I never looked at string :)
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
06 Nov 2014 01:52 PM
Strings are just words, letters, and anything else in between quotation marks.
Report Abuse
islandmaker2012 is online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
06 Nov 2014 01:54 PM
if msg:sub(1,4) == "123/" then
print(msg:sub(5))
end

example:

123/hi

output:
>hi
Report Abuse
xolbStudios is not online. xolbStudios
Joined: 05 Nov 2009
Total Posts: 504
06 Nov 2014 02:05 PM
@Jarod I know what string is. I never asked what it is

nop.
Let me ask this more clearly.
How do I find unknown text before a certain character?

say for example if i say hi/
it would print hi
if i said hellos/
it would print hellos/
so basically it finds what's before / no matter how many characters there are
Report Abuse
islandmaker2012 is online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
06 Nov 2014 02:09 PM
m= 0
if msg:match('/') then
repeat m = m+1
txt = msg:sub(m,m)
until txt == '/'
print(msg:sub(1,m))
end
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
06 Nov 2014 02:27 PM
function split(input)
local output = {}
input:gsub("[^/]+", function(word) table.insert(output, word) end)
return output
end


local text = "Hello/How/Are/You/Doing/Today?"

for _, word in pairs(split(text)) do
print(word)
end --[[>Hello
How
Are
You
Doing
Today?]]
Report Abuse
xolbStudios is not online. xolbStudios
Joined: 05 Nov 2009
Total Posts: 504
06 Nov 2014 03:00 PM
Can someone help me with another thing?
thread - http://www.roblox.com/Forum/ShowPost.aspx?PostID=149286010
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