ExtractRegularExpression, but only groups (?)

Just starting out? Need help? Post your questions and find answers here.
AZJIO
Posts: 73
Joined: Wed Dec 14, 2022 1:13 pm

ExtractRegularExpression, but only groups (?)

Post by AZJIO »

How to transform the code to get only words matching a regular expression.
The first code works correctly.

Code: Select all

var re = /^.*?([a-zа-яё\d_]*bi[a-zа-яё\d_]*).*?\|.+?\|.+?$/mgi;
var str="_arraybin|_ArrayBin|func\_ArrayBin\n_arraycom|_ArrayCom|func\_ArrayCom\n_arrayconc|_ArrayConc|func\_ArrayConc";
var myArray;
var msg = "";
while ((myArray = re.exec(str)) != null)
{
    msg = msg + myArray[1] + "\n";
}
WScript.Echo(msg);

Code: Select all

SearchTgTx$ = "_arraybin|_ArrayBin|func\_ArrayBin" + #CRLF$ + "_arraycom|_ArrayCom|func\_ArrayCom" + #CRLF$ + "_arrayconc|_ArrayConc|func\_ArrayConc"
String$ = "bi"
Dim aCompletion$(0)
If CreateRegularExpression(0, "^.*?([a-zа-яё\d_]*?" + String$ + "[a-zа-яё\d_]*?).+?\|.+?\|.+?$", #PB_RegularExpression_AnyNewLine | #PB_RegularExpression_NoCase | #PB_RegularExpression_MultiLine)
	Found = ExtractRegularExpression(0, SearchTgTx$, aCompletion$())
	Debug Found
	Debug aCompletion$(0)
	FreeRegularExpression(0)
EndIf

Code: Select all

SearchTgTx$ = "_arraybin|_ArrayBin|func\_ArrayBin" + #CRLF$ + "_arraycom|_ArrayCom|func\_ArrayCom" + #CRLF$ + "_arrayconc|_ArrayConc|func\_ArrayConc"
String$ = "bi"
Dim aCompletion$(0)
!var myArray;
!var v_re = /^.*?([a-zа-яё\d_]*v_string$[a-zа-яё\d_]*).*?\|.+?\|.+?$/mgi;
!while ((myArray = re.exec(v_searchtgtx$)) != null){
!a_aCompletion$.array[v_i] = myArray[1];
!v_i +=1;
!}
!v_found = myArray.length
Debug Found