Jump to content

Recommended Posts

Posted

Hi!

Is it possible to add a match any inside a regular expression? I am having troubles finding such something, and yet it feels powerful enough that it should be possible?

#include <Array.au3>

Local $aArray[5] = ["Test (1)", "Test (2)", "Test (3)", "Test (4)", "Test (5)"]

For $i = 0 To UBound($aArray) -1
   StringRegExpReplace($aArray[$i], " (%)", "")
Next

_ArrayDisplay($aArray)

I have tried % and *, two I've learnt from working with Windows and SQL (a bit). But alas. Am I being completely off the beaten track here? I think you can tell by looking at code and assuming % is any character, what I desire from it. Doing string logic (StringLeft etc) is considered by me cheating in this context!

Posted (edited)

Help file => . (dot) and * (asterisk)

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

So basically you want to end up with ("Test", "Test","Test","Test","Test") in your array.

Look at the Metacharacters section of the StringRegExp section of the help file. There is also a tutorial in the Tutorial section.

I can't test at the moment, but hash # might even do the trick.

  Reveal hidden contents

Fancy me, of all people, giving advice on Regular Expressions.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

  Reveal hidden contents

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Posted

TheSaint is referencing Q...E as well or you can escape by looking in my signature for _StringRegExpMetaCharacters(). Though with most of these regexp questions, it's best to show a before and after picture of what you want. As for your comment about StringLeft being a cheats choice, then I am afraid you're mistaken and will learn to appreciate that complexity doesn't mean better.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...