开发者

how make preg match allow write quotes

how make preg match allow w开发者_如何学Pythonrite quotes here is my code

preg_match('#$[a-z0-9]^#i',$text)

i want develop this regex to allow to me write " or '


For double quotes, you can just type " directly. For single quotes, since you're using them to quote the string, you'll have to use a backslash to escape them, by typing \'. (Note that this is just telling PHP to use a single quote in the string. Once it's passed to preg_match, the backslash is gone.)

BTW, your regular expression looks wrong. The $ should usually be the last character, and ^ should be the first. Unless you're trying to match multiple lines, in which case you need a m modifier at the end. For example:

preg_match('#$[a-z0-9"\']^#im',$text)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜