Jump to content

Recommended Posts

[] means a class, or posible options [abc] means a or b or c

 

so....your telling regex to match not match alot of stuff....

anyway what you want is:

 

(href="(.*?)")

 

that should work fine (as your entire expression, you dont need / / at the start and the end)

 

the data between quotes will be at result_array[1] btw

 

and the * is greedy, it matches any character AS MUCH AS IT CAN you want lazy to match it as little as posible (up until the next quote) otherwise it would match for example

 

href="stuff" more "stuff" "doo" "foo" "bar"

 

greedy regex matches:

stuff" more "stuff" "doo" "foo" "bar

 

Lazy matches:

stuff

 

the *? makes it 0 or more matches - but as little as posible.

 

Link to comment
https://forums.phpfreaks.com/topic/211440-help-with-regex/#findComment-1102421
Share on other sites

[] means a class, or posible options [abc] means a or b or c

 

so....your telling regex to match not match alot of stuff....

anyway what you want is:

 

(href="(.*?)")

 

that should work fine (as your entire expression, you dont need / / at the start and the end)

 

the data between quotes will be at result_array[1] btw

 

and the * is greedy, it matches any character AS MUCH AS IT CAN you want lazy to match it as little as posible (up until the next quote) otherwise it would match for example

 

href="stuff" more "stuff" "doo" "foo" "bar"

 

greedy regex matches:

stuff" more "stuff" "doo" "foo" "bar

 

Lazy matches:

stuff

 

the *? makes it 0 or more matches - but as little as posible.

Thanks - That does work but what Im trying to do is remove everything other than the href="test.htm" bit. How would I do that ? The only way I can think of doing this is using something like [^(expression here)] but that will match on a per letter basis.
Link to comment
https://forums.phpfreaks.com/topic/211440-help-with-regex/#findComment-1102433
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.