The regex module allows you to modify, remove or add any text or images to your RSS feed.
In this tutorial I will demonstrate my methods of tackling regex code.
I do not come from a programming background and found regex a huge challenge. My methods are not efficient so if your looking for efficiency look elsewhere .
- Load up http://gskinner.com/RegExr/
This is my favorite regex tester. There are others about.
In this example I am going to extract the digits from a link.
Images/Icons/Category/48.gif
I want to cut this link to only say ‘48’
- Enter the text you want editing to the body of the regex tester.
- You want to start at the beginning of the line. The regex for this is ‘^’
- You then want to remove all the text up until the digits you are after.
The regex for this is .+
Now you have the entire line highlighted (this is effectively deleting the entire line)
- Now you want to select the digits. The regex for this is ‘d’
Because there are two digits you need a ‘+’. The ‘+’ Takes the next character in the line.
We now have the correct amount of the line highlighted.
- Put a brackets around the digit part of the regex. In this case it would look like this, ^.+(d)
The brackets here are making the digits an output variable which can be extracted. - Now add a ‘.+’ which highlights (deletes) the rest of the line.Finished regex
^.+(d)).+ - In the regex module put a ‘$1’ to tell the module to output the digit.
No comments:
Post a Comment