Jump to content

Fairly simple regex question


Inigo

Recommended Posts

Hi Guys. This should- hopefully- be a pretty simple question for someone with regex experience to answer. I've been reading all the regex guides and tried various things but none have worked and I'm starting to get a headache. I've decided to just pitch the question here.

 

How do I test if a string contains ONLY a certain character- but could be one or more instances of that character. In this case it's a comma. So:

 

','          -> Would return TRUE

',,,'        -> Would return TRUE

',,,,,,,'    -> Would return TRUE

 

',,,hello,' -> Would return FALSE

'hi,,,'      -> Would return FALSE

 

 

Thanks in advance!

 

 

Link to comment
https://forums.phpfreaks.com/topic/231185-fairly-simple-regex-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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