physaux Posted November 5, 2009 Share Posted November 5, 2009 **EDIT: Meant to say apostrophe! I am asking because it is the prefix in my scraping, and so I need to store it exactly like that. It is searched for in regex. String below: resultTitle' id='infopei'><a href=" Any ideas? Will it work into preg_match()? Quote Link to comment https://forums.phpfreaks.com/topic/180480-how-can-i-store-a-string-with-both-collon-and-in-it/ Share on other sites More sharing options...
Daniel0 Posted November 5, 2009 Share Posted November 5, 2009 What do you mean? You just need to escape the one you're using to delimit your string. Quote Link to comment https://forums.phpfreaks.com/topic/180480-how-can-i-store-a-string-with-both-collon-and-in-it/#findComment-952132 Share on other sites More sharing options...
cags Posted November 5, 2009 Share Posted November 5, 2009 $example = "John said \"Hello bob, it's nice to meet you\". Bob didn't give a shit."; Quote Link to comment https://forums.phpfreaks.com/topic/180480-how-can-i-store-a-string-with-both-collon-and-in-it/#findComment-952144 Share on other sites More sharing options...
physaux Posted November 6, 2009 Author Share Posted November 6, 2009 tru , my bad it was that simple lol I just got scared when I couldn't copy paste it, thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/180480-how-can-i-store-a-string-with-both-collon-and-in-it/#findComment-952168 Share on other sites More sharing options...
physaux Posted November 6, 2009 Author Share Posted November 6, 2009 O shit I just realized, my delimiter is actually tilda, ~, so what can I do now? I didnt use the slash as a delimiter because I was storing urls. But now I am trying to declare a variable to hold the string: $prefix_7 = 'resultTitle' id='infopei'><a href="'; How can I do that, and make sure it works in my preg_match? Quote Link to comment https://forums.phpfreaks.com/topic/180480-how-can-i-store-a-string-with-both-collon-and-in-it/#findComment-952265 Share on other sites More sharing options...
Daniel0 Posted November 6, 2009 Share Posted November 6, 2009 Then you escape all the tildes... Quote Link to comment https://forums.phpfreaks.com/topic/180480-how-can-i-store-a-string-with-both-collon-and-in-it/#findComment-952400 Share on other sites More sharing options...
cags Posted November 6, 2009 Share Posted November 6, 2009 There are no tildes as far as I can tell. I believe the OP is confused about the difference between escape characters/delimiters with regards to PHP and with regards to Regular Expressions. Quote Link to comment https://forums.phpfreaks.com/topic/180480-how-can-i-store-a-string-with-both-collon-and-in-it/#findComment-952442 Share on other sites More sharing options...
Daniel0 Posted November 6, 2009 Share Posted November 6, 2009 Yeah I'm not entirely sure what the problem is either. We'd need more info to give accurate help. Quote Link to comment https://forums.phpfreaks.com/topic/180480-how-can-i-store-a-string-with-both-collon-and-in-it/#findComment-952451 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.