Regular expressions inside the "Replace with" field

Let us know what you would like to see in the next version of this software

Moderator: kfury77

Forum rules
Please follow these guidelines when posting feature requests. This will help to increase the value of your contribution.
  • Do not create new topics for already requested features. Add your comments to the existing feature request topics instead;
  • Create separate topic for each feature suggestion. Do NOT post a number of non-related feature suggestions in a single topic;
  • Give your topic a meaningful title. Do NOT create topics with meaningless titles, such as "My Suggestion" or "My Problem".
Please note that we DO READ all suggestions, even if a reply is not posted. Thanks!
Post Reply
raymond
Posts: 21
Joined: Fri Oct 26, 2007 4:16 am

Regular expressions inside the "Replace with" field

Post by raymond »

Hi Karlis,

One of the things that I think would be very useful is to allow us to use Regular expressions inside the "Replace with" field. For example: Let's say I want to replace all the \n\n with a \n. I would enter "\n\n" inside the "Search for" field and then enter "\n" inside "Replace with" field.
User avatar
chrisjlocke
Top Contributor
Posts: 995
Joined: Mon Aug 01, 2005 4:12 pm
Location: Essex, UK
Contact:

Re: Regular expressions inside the "Replace with" field

Post by chrisjlocke »

Moving message to Feature Requests...
User avatar
chrisjlocke
Top Contributor
Posts: 995
Joined: Mon Aug 01, 2005 4:12 pm
Location: Essex, UK
Contact:

Re: Regular expressions inside the "Replace with" field

Post by chrisjlocke »

WeBuilder allows this already, and has done for some time.
Image

Personally, I don't think you want to be using regular expressions anyway, as you are replacing normal text. The text may represent regular expressions (actually, its just PHP code) but as far as the search and replace dialog is concerned, its normal text.
User avatar
MikeyB
Top Contributor
Posts: 511
Joined: Fri Jun 09, 2006 10:38 am
Location: UK
Contact:

Re: Regular expressions inside the "Replace with" field

Post by MikeyB »

Actually the regular expressions do not work very well at all (if at all) when replacing, take this example:

Here is a small sample of some XML that I get from a GPS device, when initially viewed on the PC it is all one a single line:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns="http://www.topografix.com/GPX/1/0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mbx="http://www.motionbased.net/mbx" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.motionbased.net/mbx http://www.motionbased.net/site/schemas/mbx/0.0.1/mbx.xsd" creator="MotionBased Technolgies http://www.motionbased.com" version="1.0"><trk><mbx:gpsTrackPk>6055766</mbx:gpsTrackPk><trkseg><trkpt lat="51.682227" lon="-2.355575"><ele>77.0</ele><time>2008-03-27T14:37:13+00:00</time><course>124.54918253409951</course><speed>1.288450119285796</speed></trkpt></trkseg></trk></gpx>
To make it a bit more readable I do a regex search and replace (in my other editor) like this:
Search for: <
Replace with: \n<

And this results in:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>

<gpx xmlns="http://www.topografix.com/GPX/1/0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mbx="http://www.motionbased.net/mbx" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.motionbased.net/mbx http://www.motionbased.net/site/schemas/mbx/0.0.1/mbx.xsd" creator="MotionBased Technolgies http://www.motionbased.com" version="1.0">
<trk>
<mbx:gpsTrackPk>6055766
</mbx:gpsTrackPk>
<trkseg>
<trkpt lat="51.682227" lon="-2.355575">
<ele>77.0
</ele>
<time>2008-03-27T14:37:13+00:00
</time>
<course>124.54918253409951
</course>
<speed>1.288450119285796
</speed>
</trkpt>
</trkseg>
</trk>
</gpx>
Do the same search & replace in WeBuilder I end up with:

Code: Select all

\n<?xml version="1.0" encoding="UTF-8"?>
\n<gpx xmlns="http://www.topografix.com/GPX/1/0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mbx="http://www.motionbased.net/mbx" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.motionbased.net/mbx http://www.motionbased.net/site/schemas/mbx/0.0.1/mbx.xsd" creator="MotionBased Technolgies http://www.motionbased.com" version="1.0">\n<trk>\n<mbx:gpsTrackPk>6055766\n</mbx:gpsTrackPk>\n<trkseg>\n<trkpt lat="51.682227" lon="-2.355575">\n<ele>77.0\n</ele>\n<time>2008-03-27T14:37:13+00:00\n</time>\n<course>124.54918253409951\n</course>\n<speed>1.288450119285796\n</speed>\n</trkpt>\n</trkseg>\n</trk>\n</gpx>
Still all on a single line. It's simply inserted "\n" instead of a new line

It's only the search that uses regex rather than the replace.
User avatar
chrisjlocke
Top Contributor
Posts: 995
Joined: Mon Aug 01, 2005 4:12 pm
Location: Essex, UK
Contact:

Re: Regular expressions inside the "Replace with" field

Post by chrisjlocke »

Unsure if its meant to work like that or not. Looking at the help, it would suggest so.

A workaround (or, how it also works!) is to click 'Multiline' then search for < and replace with <_ (substitute the _ for pressing return) (or _<, depending on your preference)
User avatar
MikeyB
Top Contributor
Posts: 511
Joined: Fri Jun 09, 2006 10:38 am
Location: UK
Contact:

Re: Regular expressions inside the "Replace with" field

Post by MikeyB »

Nice one, that does indeed work, good find :)
Post Reply