Jump to content

letters, one comma and one space


crackpanda

Recommended Posts

Could you give an example of input and desired output? What silkfire has given will match the literal string 'A-Za-z ,'. I'm guessing for your first question you were looking to match something more like 'said, '?

 

In which case you will need to alter the pattern to look like:

/[A-Za-z]+, /

 

Placing the A-Z in the square brackets makes it a character class and will search for letters A to Z. Not inside the square brackets is just looking for the literal string 'A-Z', not the required result right? Also, you will not want the ^ sign at the beginning and the $ sign at the end. That will mean that the regex has to match from the beginning (^) till the end ($) of the input string. Again I'm presuming as you didn't provide an example with your question, but it sounds like you are looking for a match in a large section of text?

 

Hope this helps,

Joe

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.