RegExMatch question

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
afe
Posts: 615
Joined: 06 Dec 2018, 04:36

RegExMatch question

22 Jan 2019, 09:09

Hello,

Why is the value of b not 2?
Note that there is a space after 1.

Code: Select all

a := "
(
1 
2
)"
RegExMatch(a, "(?<=\s)[^\s]*", b)
msgbox % b
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: RegExMatch question

22 Jan 2019, 09:24

select one

Code: Select all

a =
(
1 
2
)
or

Code: Select all

a := ""
. 1 "`n" 
. 2
If you have made that variable intentionally, sorry. It looks like meaningless.
afe
Posts: 615
Joined: 06 Dec 2018, 04:36

Re: RegExMatch question

23 Jan 2019, 10:07

Is \s not able to match `n?
MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: RegExMatch question

23 Jan 2019, 10:19

If you want to match new line characters I recommend using \R as this can match `r,`n, `r`n.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: RegExMatch question

23 Jan 2019, 10:37

the value of b is 2
ur continuation section resolves to 1`n2, so
match 0 or more non-whitespace char(s), preceeded by a whitespace char
matches 2

to keep the space in the continuation section u have to use RTrim0
\s does match newlines
afe
Posts: 615
Joined: 06 Dec 2018, 04:36

Re: RegExMatch question

23 Jan 2019, 23:35

I gave the wrong example. The value of the above example b is 2.

I would like to ask the following example, why the value of b is not 2.

Code: Select all

a := "
(
1                                  

2  




)"


RegExMatch(a, "(?<=\s)[^\s]*", b)
msgbox % b
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: RegExMatch question

24 Jan 2019, 03:53

swagfag already gave you the Correct translation.
Read it again and find it with your fingers.
"match 0 or more non-whitespace char(s), preceeded by a whitespace char"
Remember, AHK's RegExMatch works only once starts from the beginning.
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: RegExMatch question

24 Jan 2019, 04:04

and
Obviously, you are ignoring my previous comments.
If you are ignoring the Help file, you can NOT find any solution you wanted.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: RegExMatch question

24 Jan 2019, 04:53

again, i dont get why u persist with these spaces. they will be omitted, unless u use RTrim0
ur continuation section contains 1`n`n2`n`n`n`n
(?<=\s) matches the first `n
the next char is another `n, so [^\s]* matches.... nothing, and the regex is done
SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: RegExMatch question

24 Jan 2019, 23:25

afe wrote:
23 Jan 2019, 10:07
Is \s not able to match `n?
Looks like you are confusing yourself. There is an alternative way to do it, if you simply want to know what's in a particular row. As long as you know the row of what you want, it can be simple to get. Just so you know.

Code: Select all

a =
(
1 
2
)

Loop, parse, a, `n
{
	if (A_Index = 2)
	{
	Output := A_Loopfield
	}
}
msgbox % Output
Otherwise, study on the advice the others have given.
afe
Posts: 615
Joined: 06 Dec 2018, 04:36

Re: RegExMatch question

25 Jan 2019, 02:28

I see. (?<=\s)[^\s]+ is correct, not (?<=\s)[^\s]*.
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: RegExMatch question

25 Jan 2019, 03:26

You rude
Shame you
You'd better write short reply saying "t.h.a.n.k.s." to the member who dumped its own precious time because of your idiot post.
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: RegExMatch question

25 Jan 2019, 12:48

settle down people.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google Adsense [Bot], yuu453 and 301 guests