I’m trying find a subtstring of a string using regex. My string is:
<p><a class="twitter-share-button" RANDOM STUFF HERE </script>
I know there is no script tag in the random stuff so i made a regex that looks like this:
<p><a class="twitter-share-button"[^</script>]*
But the [^</script>] excludes all characters: <, /, s, c, r, i, p, t, >
How can i tell the regex to continue searching until it finds an occurrence of the closing script tag ?
Thanks
Depends on the engine, but you can do an ungreedy match:
The
?makes the*ungreedy, so it will match everything up until the first</script>.