Jump to content

New to Regex


cry of war

Recommended Posts

Hello im kind of new to regex i know the very very basic basics like [0-9] and [a-z] but i have a few if strings that i need a regex for so i can See if the whole value or string is only numbers or only letters

 

Numbers

1235415=>true

1244p123=>false

.12235135=>false

and so on

 

Letters

aldkfjalsdf=>true

adflkjadfl1=>false

.aldkfjasldf=>false

and so on

 

if (preg_match($match,$string))
		{
		$x="2";
		}

 

any help with this problem(lack of knowledge) would be greatly appreciated

Link to comment
Share on other sites

I was looking for a regex that tells you that the whole string is or is not only letters or is or isnt only letters

 

1235415=>true (all numbers)

1244p123=>false (not all numbers because of "p")

.12235135=>false (not all numbers because of ".")

and so on

 

Letters

aldkfjalsdf=>true(all letters)

adflkjadfl1=>false(not all letters because of "1")

.aldkfjasldf=>false(not all letters because of ".")

 

would i use preg_match_all will it check to see if the whole string only has only letters or only numbers??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.