Website Toolbox Pro

Need Help With Regular Expression?

Javascript, Regular Expressions Comments »
Hi all,
I need help with Regex (Regular Expression).

For example there's a webpage on a website, and I want to get the first link on that webpage, after certain words.
"Website from is awesome"

question: how to get the link only

Here's a solution using javascript:

var strW = "website from com/blabla.php?var=blabla&se=3290 is awesome";
var regW = /(website|Website).* (http[^\s]*).* (awesome|great)/;
if (regW.test(strW)) alert (RegExp.$2);

Add/delete the key words preceding and following the URL. The URL is referenced using RegExp.$2

Regex Help?

Regular Expressions Comments »
What would be a string to replace:

This is $1.00. Ain't that nice
$1.00 for this stuff.
Buy this now for $1.00

with the format:

$1.00 {rest of the stuff from string}
so the output would be.
$1.00 This is . Ain't that nice
$1.00 for this stuff.
$1.00 Buy this now for

Continue reading Regex Help? »

Regular Expression For Validating A String Which Contains Only Characters?

Javascript, Regular Expressions Comments »
Regular expression for validating a string which contains only characters in Javascript?

Continue reading Regular Expression For Validating A String Which Contains Only Characters? »

What’s The Regex For The Following? (PHP)?

PHP / MySQL, Regular Expressions Comments »
I want to do a preg_split to get all the subnodes of the following in an array. I want to match everything between the <Subscriber> tags, but note that the first has XMLNS.

<Subscriber xmlns:xsd="">
    <Date>2008-04-11 15:00:00</Date>
    <CustomFields />
    <Name>Mark Reeves</Name>
    <Date>2008-04-11 14:37:00</Date>
    <CustomFields />

What’s the regex to use with preg_split to get <Email> through <CustomFields/> into array nodes?


Continue reading What’s The Regex For The Following? (PHP)? »

Struggling With Perl Regular Expression

Regular Expressions Comments »
I have a series of words followed by a pre-determined marker (say the letter x in this case) contained in a string.

$contents = 'test1x     test!x     test2x';

There is a need to extract a list of those words that contain only alphanumeric characters plus the marker, ‘x’. So obviously “test!x” not wanted.

If I run the following regex:

@filtered_list =
  $contents =~  /(?:[\w]+) /g

Then I get the following list returned:

("test1x", "x", "test2x")

as opposed to a required list of

("test1x", "test2x")

The problem is with the 2nd item – it fails on the character “!” and just moves on to the next character when I really want to just stop right there and not return anything for this word.

I know I am just not seeing something completely obvious…

Thank you.

Continue reading Struggling With Perl Regular Expression »

Are These Two Regex’s Equivalent?

Regular Expressions Comments »
These two regex’s should be equivalent, right?

Test your regular expressions with the Regular Expression Creator.

Javascript: Variables Within Regex?

Javascript, Regular Expressions Comments »
Is it possible to use a variable within a regular expression declaration? For example:

var findThs="test123";
var mystring = "This is some test123 text";
var result = myString.match(/findthis(?:,| |$)/);

This doesnt return a result since findthis is being interpreted as text rather than a variable. I want its contents to be inserted into the regex expression.

Continue reading Javascript: Variables Within Regex? »