I am having some issues wrapping my head around regular expression.
I have the following type of string I need to parse/get data from
'Account'.Search = "[Id] is NULL OR NAME = ""0%"""
'Account'.Sort = "NAME, Address"
'Bank Objectives'.Search = "[Active Flg] = "Y""
'Bank'.Search = "[Id] is NULL"
'Bank'.Sort = "Transit"
'Bank Goals'.Search = "[Active Flg] = 'Y'"
.......
The following expression seems to work
\s*(?:(?<search>(?:(=['"])?(?:.*)\1|.*)\.Search[^"']*(?:(=['"])?(?:.*)\1|.*))\s*$?(?<sort>(?:(=['"])?(?:.*)\1|.*)\.Sort[^"']*(?:(=['"])?(?:.*)\1|.*))?\s*$?)
And I can get the output like
search: 'Account'.Search = '[Id] is NULL OR NAME = ''0%'''
sort: 'Account'.Sort = "NAME, Address"
search: 'Bank Objectives'.Search = "[Active Flg] = "Y""
search: 'Bank'.Search = "[Id] is NULL"
sort: 'Bank'.Sort = "Transit"
search: 'Bank Goals'.Search = "[Active Flg] = 'Y'"
However if the input string doesn't have line returns, then I start to get
search: 'Account'.Search = '[Id] is NULL OR NAME = ''0%''''Account'.Sort = "NAME, Address"
What I really basically from the input string is
Account
Search = "[Id] is NULL OR NAME = ""0%"""
Sort = "NAME, Address"
Bank Objectives
Search = "[Id] is NULL OR NAME = ""0%"""
Sort = ""
.....
Also the (=['"])?(?:.*)\1|.*)
is suppose to match quotes, but it doesn't seem to be working either.
The end goal is to pass the string [Id] IS NULL or Name =""0%"""
to an expression editor, allow the user to make changes and then just update the search portion of the overall string, so if the user wants the account name that starts with bob
, I would need to generate
'Account'.Search = "Name like 'bob%'"
'Account'.Sort = "NAME, Address"
'Bank Objectives'.Search = "[Active Flg] = "Y""
'Bank'.Search = "[Id] is NULL"
'Bank'.Sort = "Transit"
'Bank Goals'.Search = "[Active Flg] = 'Y'"
.......
I already have that piece built, it is parsing this string which can have multiple entries. Also the string could just contain
"Name like 'bob%'"
So it is left to me to figure out that it was suppose to actually be
'Account'.Search = "Name like 'bob%'"
So I need to know if the input string even matches the regex