Forum Moderators: coopster

Message Too Old, No Replies

Regex: How do I match a dot?

         

Joe Belmaati

2:01 pm on Nov 18, 2004 (gmt 0)

10+ Year Member



I am trying to match the dot, so that it actually matches "a dot" and not "everything". How do I write that? Example: the word "st."

I have tried
'/\bst.\b/i'
'/\bst\.\b/i'

Sorry if this question is noobish. I have not been able to find the answer searching the net.

Help is much appreciated!
Sincrely
Joe Belmaati
Copenhagen Denmark

Salsa

2:31 pm on Nov 18, 2004 (gmt 0)

10+ Year Member



Putting a backslash in front of special characters,
. *? + [ ] ( ) { } ^ $ ¦ \

should make a literal match. In your second example, maybe there is a different error. For example, if you are trying to match a literal \, you need to use \\ in order to escape the \ and make it literal.

Joe Belmaati

2:59 pm on Nov 18, 2004 (gmt 0)

10+ Year Member



Thank for the reply, Salsa :)
I actaully found out that my problem was the word boundaries \b
I also tried to pack the expression into ^ and $ with the same non-result. I am not sure how I would add bounadaries to make the expression work. Right now I've got
'/st\./i'
but that only goes half way towards my goal as it would also match the (unlikely) event that a word had st. in the middle of it...