Regular expression Problem

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
j123258
Posts: 7
Joined: 08 Dec 2017, 12:12

Regular expression Problem

20 Jan 2018, 12:57

Hi,
l have a problem with regular expression.

I want to match a string and it have some rules, but I don't know how to express it through regular expression.

For example, I want to match "xbcd". (where x can be any character)
For exmaple ,"xbcd" matches "rbcd","obcd","pbcd" but not "abcd" , "wbcd" or "bcd".

Does anybody know how to express it?
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Regular expression Problem

20 Jan 2018, 13:08

Hello, needle := "[rop]bcd" matches, eg, haystack := "rbcd" but not haystack := "abcd".

Cheers.
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Regular expression Problem

20 Jan 2018, 13:36

Hi j123258,

You will need to specify for this, as indicated by Helgef, a class of characters. See in particular the 'Classes of characters' part of the RegEx quick reference. Example with the 'NOT version' instead which can be I think - and depending on your goal and the nature of input - just as relevant:

Code: Select all

for each, string in ["rbcd","obcd","pbcd","zbcd","abcd","wbcd", "bcd"]
{
	RegExMatch(string, "[^awc]bcd", match)
	MsgBox % match
}
Hope this helps.
my scripts
j123258
Posts: 7
Joined: 08 Dec 2017, 12:12

Re: Regular expression Problem

20 Jan 2018, 22:36

Thank you for your answer,Helgef and A_AhkUser.

I just started learning RegEx, It is so interesting.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Rohwedder and 421 guests