tags:

views:

67

answers:

3

i need to find regex that suitable with this..

[url]%252FShowOneUserReview-g298570-d301416-
r63722677%26sl%3Dzh%26tl%3Den_US%26hl%3Den_US%26ie%3DUTF-8

its situated in <a href/redirect.. and combine with other url such as url=http://translate.google.com/translate[url]

is it possible for me to find only [url]...-8?

A: 

The following should match [url] ... -8:

\[url\].*-8

VeeArr
thnks..the one that im grabbing is actually is url. i want to download that url. how can i do that?..thnks in advance
newBie
+1  A: 

You should always clarify which language you're using when you ask regular expression questions, and your question is rather vague to begin with, but essentially the pattern you want seems to be:

\[url\](.*)-8

This captures the part you want into group 1 (see it on rubular.com).

How this translates into your language may vary; you may have to double the \ in, e.g. Java. If this pattern doesn't work, then simply add some test strings into rubular and be clear about your expectations and I'll work it with you.


Another possibility

It's possible that perhaps you have a bunch of [url]...[/url] "elements" in the page, and you just want to grab the ones that are ShowOneUserReview? Then perhaps something like this is what you want (see it on rubular.com):

\[url\]([^[]*ShowOneUserReview[^[]*)\[\/url\]

This grabs all [url]...[/url] that contains ShowOneUserReview somewhere within it. This is not foolproof, but unless you're very clear on the requirement, we can only guess what you're trying to do.

polygenelubricants
A: 

Try matching

\[url\](\S+-8)

This will match any run of non-space characters up to the last possible -8. I chose \S over . because otherwise you might match too much (more than the link itself).

It might be even safer to use

\[url\](\S+-8)\b

to ensure we're not matching

[url]%252FShowOneUserReview-8

in

[url]%252FShowOneUserReview-8570-d301416-r63722677%26sl%3Dzh%26tl%3Den_US%26hl%3Den_US%26ie
Tim Pietzcker