Sign in to follow this  
Followers 0
FaridAgl

StringRegExp Help...

12 posts in this topic

#1 ·  Posted (edited)

Well, I have no clue on StringRegExp(), would be nice if someone give some little helps.

The code explains itself:

Global Const $TEXT_A = "SpeCtR3._.n1 - SpamBot" ;Needs SpeCtR3._.n1
Global Const $TEXT_B = "D4RK-ON3 - Server 2" ;Needs D4RK-ON3
Global Const $TEXT_C = "EXuCHER - WhisperBot" ;Needs EXuCHER
Global Const $TEXT_D = "Whatever here A - Whatever here B" ;Needs Whatever here A

As commented in the code, the output of StringRegExp() should be everything before the last dash (-), note that there could be more than one dash ($TEXT_B).

Thanks in advance.

Edited by D4RKON3

Share this post


Link to post
Share on other sites



In the helpfile there is a script that is actually a StringRegEx tool. Look in the Tutorial section > String Regular Expression. At the bottom of the page is the button to open the script in SciTE. Run it and the tool will make it much easier to figure out what you have in mind. Also, read the tutorial. It helps!

1 person likes this

Share this post


Link to post
Share on other sites

In the helpfile there is a script that is actually a StringRegEx tool. Look in the Tutorial section > String Regular Expression. At the bottom of the page is the button to open the script in SciTE. Run it and the tool will make it much easier to figure out what you have in mind. Also, read the tutorial. It helps!

Thank you, I found that.

Share this post


Link to post
Share on other sites

did you even look at the tool?

I saw your post after I post, I'm looking on it now.

Share this post


Link to post
Share on other sites

The tool doesn't help so much as I'm don't know much (anything) about Regular Expression, would be nice if some expert do me this favor.

The first post is still available!

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

this will do the job

StringRegExp($TEXT_A,"(.*?)\-(?:.*?)\z",3)

for multiline, you need to replace z with r or n

EDIT:

() --> Capturing group

.*? --> Matchs every character (.), 0 or more times (*), fewer possible (?)

- --> Dash escaped (to escape a char. use back slash)

(?: ... ) --> Non capturing group (just for reference)

z --> Marks string end

so if you read it, capture every characters behind a dash, and do not capture the existing chars between a dash and string end

Edited by DiOgO

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Share this post


Link to post
Share on other sites

Thank you my friend.

For $TEXT_B it returns "D4RK" instead of "D4RK-ON3".

For the others, it has a whitespace " " at the end.

Share this post


Link to post
Share on other sites

Thank you my friend.

For $TEXT_B it returns "D4RK" instead of "D4RK-ON3".

For the others, it has a whitespace " " at the end.

just add a space before - or put a dot (match a character)

works fine for me:

Global Const $TEXT_A = "SpeCtR3._.n1 - SpamBot" ;Needs SpeCtR3._.n1
Global Const $TEXT_B = "D4RK-ON3 - Server 2" ;Needs D4RK-ON3
Global Const $TEXT_C = "EXuCHER - WhisperBot" ;Needs EXuCHER
Global Const $TEXT_D = "Whatever here A - Whatever here B" ;Needs Whatever here A
$reqa = StringRegExp($TEXT_A, "(.*?) \-(?:.*?)\z", 3)
$reqb = StringRegExp($TEXT_B, "(.*?) \-(?:.*?)\z", 3)
$reqc = StringRegExp($TEXT_C, "(.*?) \-(?:.*?)\z", 3)
$reqd = StringRegExp($TEXT_D, "(.*?) \-(?:.*?)\z", 3)
MsgBox(0, "", $reqa[0] & @CRLF & $reqb[0] & @CRLF & $reqc[0] & @CRLF & $reqd[0])
Exit

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Share this post


Link to post
Share on other sites

you're welcome

DiOgO


Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Share this post


Link to post
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
Sign in to follow this  
Followers 0