Regex Pattern Replace

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Monoxide3009
Posts: 65
Joined: 09 Apr 2018, 15:53

Regex Pattern Replace

22 May 2018, 18:28

Hello All,

I have tried to understand how the regex works with autohotkey, but I am coming up blank on everything I do for the most part.

I was self taught in perl regex as it functions in the Kapow Design Studio, so I (assume I) understand the concept, but not how to write it in AHK.

For example, one of the current pattern matches I am working on is similar to this:

COMPANYrandomtext Business (B4) ; I am looking to pull specifically the information in parenthesis "B4"

Kapow made regex patterns very simple in that you would use perl expressions in box A to form patterns, then chose what to pull using $1, $2, $3 as they relate to what is in parenthesis in your pattern.

Example: COMPANYrandomtext Business (B4)

Box 1 -
.*\((.*)\).*
.* would represent anything, the \( is an escaped parenthesis, and the (.*) is the pattern I am looking for.

Box 2 -
$1
This would output a variable of whatever is within the parenthesis.





I assume I am making this way more complex than it needs to be, but that is why I am here =\

Any help on how to pull from a pattern would be greatly appreciated (or any other way to get the info I seek). I am also **VERY** self taught, so the more layman you can make your response, the better.

Thanks in advance!
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Regex Pattern Replace

22 May 2018, 19:25

Code: Select all

hs = COMPANYrandomtext Business (B4)

RegExMatch(hs, "(?<=\().+?(?=\))", results)

msgbox, % results
Monoxide3009
Posts: 65
Joined: 09 Apr 2018, 15:53

Re: Regex Pattern Replace

22 May 2018, 19:35

Thanks!

It works, now I just have to reverse what each piece means and ill be golden =p

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Holarctic, Rohwedder and 191 guests