lonewolf217 Posted October 24, 2008 Share Posted October 24, 2008 I am very new to regex and still very confused. I am slowly learning from online tutorials but I cannot figure out how I can match double slashes "\\" like from a UNC path for a preg_replace any help is appreciated Link to comment https://forums.phpfreaks.com/topic/129955-regex-question-to-match/ Share on other sites More sharing options...
ghostdog74 Posted October 24, 2008 Share Posted October 24, 2008 no need regex if ( strpos($string,'\\') !==FALSE) { echo "found"; } check the online PHP manual for string functions. Link to comment https://forums.phpfreaks.com/topic/129955-regex-question-to-match/#findComment-673720 Share on other sites More sharing options...
lonewolf217 Posted October 24, 2008 Author Share Posted October 24, 2008 Well I know i can find it easily, but I am actually trying to do a preg_replace on it .. so i need regex. perhaps I wasn't clear enough in my initial post. I want to match the entire UNC string, which I think I can do on my own I just cannot figure out how to match the initial part of the double backslash Link to comment https://forums.phpfreaks.com/topic/129955-regex-question-to-match/#findComment-673741 Share on other sites More sharing options...
effigy Posted October 24, 2008 Share Posted October 24, 2008 %\\\\\\\% First you have to consider PHP's escaping rules, then the regex rules, which results in a double escaping effect. Link to comment https://forums.phpfreaks.com/topic/129955-regex-question-to-match/#findComment-673787 Share on other sites More sharing options...
sasa Posted October 24, 2008 Share Posted October 24, 2008 try <?php $text = 'blah\\blah'; echo preg_replace('/\\\\/','xxx', $text); ?> Link to comment https://forums.phpfreaks.com/topic/129955-regex-question-to-match/#findComment-673794 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.