Devator
Devator

Reputation: 3904

How do I find a string in string with regex?

Despite my many efforts to learn RegEx, I find this quite hard todo, so I'm asking the community for help.

So, I have this string:

<html><head>
<title>Test</title>
</head>
<body>
<a href="goforward?U=as4395897a8druasfdas833a">Go</a>
</body>
</html>

Now I want to find as4395897a8druasfdas833a using a regex. This code is not inside an "" in the real word, although I would like to search for "goforward?U" (that one is always the same).

Thanks in advance.

Upvotes: 1

Views: 148

Answers (3)

user470714
user470714

Reputation: 2888

This should work:

goforward\?U=[a-z0-9]+

Upvotes: 4

vbence
vbence

Reputation: 20333

Try with this:

goforward\?U=([a-z0-9]+)

Upvotes: 2

Josh M.
Josh M.

Reputation: 27783

In your example code, this would work:

goforward\?U=(\w+)

But more information is needed to get it more precise. Since I don't know what "actually" contains or what ends the term you want to find I can't give an exact regular expression so if you comment with more details I can tweak it.

Upvotes: 6

Related Questions