Regex and preg experts please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BradM
    Confirmed User
    • Dec 2003
    • 3397

    #1

    Regex and preg experts please

    Guys I am trying to use preg to pull a string in.
    The string starts with src=" and ends with image.jpg

    The middle is variable. I need to pull the entire string using the start and end of it from a page I am fopen-ing. This page is stored in a string. So I have the data here but it's a full html page. So I am going into $source, and I am trying to pull that specific string.

    Anyone have some suggestions? It would be a snap if I knew what the middle of the string was, but it's *.

    Thanks!
  • psili
    Confirmed User
    • Apr 2003
    • 5526

    #2
    This is probably too greedy of a regex, but you can try:

    preg_match("/src=\".*image.jpg\"/",$source,$matched);
    Your post count means nothing.

    Comment

    • natkejs
      Confirmed User
      • Jan 2003
      • 1640

      #3
      /src\=\"(.*?)image\.jpg/isU

      yes? no? maybe?

      I dunno I suck at that shit and I didn't try that expression but it should be somewhere in the neighbourhood of what you're looking for at least.

      Comment

      • fuzebox
        making it rain
        • Oct 2003
        • 22372

        #4
        Originally posted by natkejs
        /src\=\"(.*?)image\.jpg/isU

        yes? no? maybe?

        I dunno I suck at that shit and I didn't try that expression but it should be somewhere in the neighbourhood of what you're looking for at least.
        Looks right to me

        Comment

        • BradM
          Confirmed User
          • Dec 2003
          • 3397

          #5
          Man I am getting good, I was just missing a "."
          Thanks for the help guys, I appreciate it.

          Comment

          Working...