Jump to content

how do you escape ^ in regex?


Recommended Posts

I want to replace number begins with ^ (powering symbol). echo preg_replace('^(\d+)', '<\\0>', $str)."\n"; gives meWarning: preg_replace(): No ending delimiter '^' found in C:\Users\rain\Desktop\blah.php on line 16 and echo preg_replace('\^(\d+)', '<\\0>', $str)."\n"; gives meWarning: preg_replace(): Delimiter must not be alphanumeric or backslash in C:\Users\rain\Desktop\blah.php on line 16 any ideas?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...