Search a specific word


I have this pattern which help me to extract the second parameter of the STRING command:

: (?mi)(?!.*sub|.*replace[\S]|.get localize[\d])string(([^;{1}]+;)(.?)(;|))+

It works well to ignore the substring command, but no operand with ‘replace string’ or ‘get localize string’.
Any idea to reach it?


maybe the wildcard is too aggressive?

you could rewrite the pattern using look-behind assertions.


If(Match regex("(?i)(?<!sub|replace\s|get\slocalized\s)string(?:C10)?\s*[^;]+;([^\)])";$t;1;$pos;$len))


End if


Does it have to work in all cases?

Because I think it’s almost impossible to compose a regex that will always meet the need. The first parameter can be complex in itself.

Yes it does work in any case.
Exactly, all the issue is around the first parameter and there is the question.

I will test Keisuke solution this evening and let you know.


In my opinion, this is typically a problem that regex can’t solve.
You can’t assume the first semi-colon you meet belongs to the string command. It could be part of the first parameter.
It will work in some cases but not all.

You’re absolutly right.
If 'im not able to manage this specific case like:
string(field(table;3);“My format”), may I will make a restriction, but I would really like to be able to find a solution.
If not, I guess to be able enough right in 99% and alert in the 1% other case.

I’ve time and help is greatfull appreciate on this topic.
Anyway, I’ll continue to try in this way this week

If the goal is to extract the second parameter from the string command, you can try this pattern:


If the command is at the end of the line.
If it is not followed by comments.
If it has only two parameters.
If the second parameter is not complex.

There is an interessant idea in your pattern.
But it not reach totally the goal.

Yes, a lot of ‘If’, but it is not funny in another case :wink:

To help,

here are my test cases:
<code 4D>
STRING LIST TO ARRAY(“khkjhjhkjkj”;“strin list to array”)
$x:=get localized string(“sdsdssd”;“localize”)
string(field(3;3);“My Style”)
$CheminAcces:=Get 4D folder(Database folder;*)+replace string(“Thefolder/”;"/";Folder separator)
replace string(“Trace/”;"/";Folder separator)
replace string(“khhjk”;“replace”;“kjjhkkhj”)
ResteAPayer:=Choose([Factures]Payee_VF=False;“Il reste à toucher “+String([Factures]Reste_A_Payer;”### ##0,00”+<>Symbol);“Facture Payée”)
ALERT(Get localized string(“Désigner au moins un ensemble”))

</code 4D>

I’m also using the> website to test the pattern.

yes, you must improve with the possibility of comments or others code
before the end of line
no, this pattern run with more than two parameters
yes, the second parameter is complex you have to manage it.

It was just a response to the question: : Patrick EMANUEL

If 'im not able to manage this specific case like:
string(field(table;3);“My format”)

But the goal isn’t describe enough to be able to give a complete answer.

With the REGEX patterns, it’s always easier to describe what you do not want than what you think you can find (we always forget something…)

You’re right Vincent, i’m currently playing with comments and codes and the part you provide to me help me to select the second parameters.
The goal is to catch the format information to fill an array with it.
Anyway, I will continue to try different possibility and no-one is ok, I will keep the one will provide (for me) the best response.

I agree with you Vincent.
Your proposal is smart but the goal is unreachable with regex.
It depends on the precise goal though.


here is my best pattern
(?mi)(? < !sub|replace\s|get\slocalized\s)string[^\s].+?(;[^(][^)|;]*)

:pray:(Just remove spaces placed before and after < sign. Editor doesn’t display correctly the pattern in other case.)

It matches all cases except this one:
<code 4D>
string(field(3;3);“My Style”)
</code 4D>

which is string command using another command as first parameter.

If anyone is able to solve it, fine, in another, not a big deal, just a confirmation that I will manage with another pattern :wink:

Thanks all for your help.