Jump to content
  • 0

How to check if there is a special character in input


Poring King

Question


  • Group:  Members
  • Topic Count:  61
  • Topics Per Day:  0.02
  • Content Count:  911
  • Reputation:   166
  • Joined:  11/27/14
  • Last Seen:  

Hello is there a way to check if there is a special character in input ? I tried "If (compare())" condition . Can you give me idea how properly check if there is a special character with in input

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   7
  • Joined:  08/05/16
  • Last Seen:  

Try using

*preg_match(<regular expression pattern>,<string>{,<offset>})

Searches a string for a match to the regular expression provided. The
offset parameter indicates the index of the string to start searching.
Returns offsets to captured substrings, or 0 if no match is found.

This command is only available if the server is compiled with the regular
expressions library enabled.

 

Something like this could work:

if (preg_match("^[a-zA-Z0-9]+$",.@yourString$)
{
	// This means it found a coincidence, meaning that no symbols where fund
}
else
{
	// No matches, symbols where found
}

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  61
  • Topics Per Day:  0.02
  • Content Count:  911
  • Reputation:   166
  • Joined:  11/27/14
  • Last Seen:  

@Songbird I read this on script_commands.tx . I guess i did not really understand this on txt file . But right now i understand this Thankyou!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...