Jump to content

Question about StringRegExp


Anas
 Share

Recommended Posts

Hello

Is it possible to exclude a group of characters from the returned results without grouping the surrounding characters and splitting the results?

e.g. if $String contains 'aaabbbccc' the returned result should be:

$Res[1] = aaaccc

not:

$Res[1] = aaa

$Res[2] = ccc

thanks

Link to comment
Share on other sites

Wrong function. Try StringRegExpReplace().

Global $sText = 'aaabbbcccdddeee'

$sText = StringRegExpReplace($sText, "[bd]", "")

MsgBox(64, "Result", $sText)

:unsure:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I can't use StringRegExpReplace, because I have a list of patterns that StringRegExp loops through and each group of characters has its own matching characters. I only want to exclude the 'non-Capturing' groups which may or may not be there.

I take it that it can't be done using StringRegExp?

Link to comment
Share on other sites

Something like that?

$string =   "aaabbbccc" & @CRLF
$string &=  "fffaaahhhccccuuu" & @CRLF
$string &=  "qqqaaajjjjcccciiii" & @CRLF
$string &=  "aaacccciaaacclllaaa" & @CRLF
MsgBox(0, "StringEx", StringRegExpReplace($string, "[^a|^c|\s]", ""))

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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