Jump to content

afrojojo

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

afrojojo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Awesome! Thanks.
  2. Hello masters of the regex. I would like your help. I need an expression that would extract the version out of this string. Everything between the last "-" and ".". INPUT: database_name-10182011946-v1.0.2.sql OUTPUT: v1.0.2 Any ideas?
  3. I guess I should update that one.
  4. Try this: if (ereg('[^A-Za-z0-9]', $text)) { echo "This contains characters other than letters and numbers"; } else { echo "This contains only letters and numbers"; }
  5. I think I got it. Adding the ENT_NOQUOTES seemed to do the trick. It was encoding the quotes and messing it up. $string=htmlentities($string,ENT_NOQUOTES); Thanks for all your help. I appreciate it.
  6. I figured out the issue. I applied htmlentities. $string=htmlentities($string); Any way around this? I don't want any other html code displayed.
  7. $string = '<a href="http://yahoo.com">Yahoo</a>'; $pattern = '/((?:https?):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$])/i'; if(preg_match_all($pattern, $string, $match)) { $string=$match[0][0]; echo $string; } Output http://yahoo.com">Yahoo</a>
  8. Oops... /((?:https?):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$])/i
  9. $pattern = '/((?:https):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$])/i'; if(preg_match_all($pattern, $string, $match)) { $string=$match[0][0]; echo $string; } Input: http://yahoo.com this is some text Output http://yahoo.com The above is ok Input <a href="http://yahoo.com">Yahoo</a> Output http://yahoo.com" I want to remove that last quote.
  10. I suppose I should rephrase this. I want it to stop at the first space, the SECOND quote, or the SECOND apostrophe, and begin at http:// or https://
  11. $pattern = '/((?:https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$])/i'; if(preg_match_all($pattern, $string, $match)) { $string=$match[0][0]; echo $string; } I came up with that using preg_match_all. It's almost what I want. $string = "<a href="http://google.com">Google</a> this is some text http://yahoo.com this is some texthttp://msn.com"; If the string was what I have above, how do I make the pattern stop at a " or '. Otherwise the first string produced would be http://google.com">Google</a>. I just want it to be http://google.com. It only stops at the first space. I would like it to stop at the first space, the first ", or the first '. So I would want the output of $string=$match[0][0] to be http://google.com. The output of $string=$match[0][1] to be http://yahoo.com, and so on.
  12. One more question. Is there a way to choose which match in the string it gets? match[1] = The first url in string match[2] = The second url in string
  13. Thanks Zach
  14. I've searched. I couldn't find anything. Thats not what my question was related to. I tried that. Doesn't work.
  15. Doesn't work
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.