Home > Software engineering >  Regex to extract an "id" separated by string (or begin)
Regex to extract an "id" separated by string (or begin)

Time:12-20

I need to extract IDs from a string : 1;#ChapitreA;#2;#ChapitreB;
Here, IDs are 1 and 2

I tried (^|;#)([0-9]?)(;) but it returns too many results => Here

Or behind :

0-2     1;
0-0     null
0-1     1
1-2     ;
12-16   ;#2;
12-14   ;#
14-15   2
15-16   ;

Constraint : I cannot use groups as this RegEx will be use in Nintex Workflow which doesn't support it. By the way I can't use any programming language neither to manage the result.. I need the RegEx to return the exact result I need (IDs) and nothing more.

Solution : (?:(?<=^)|(?<=;#))\d (?=;)

CodePudding user response:

Using groups : (?:^|;#)(\d );
Without using groups : (?:(?<=^)|(?<=;#))\d (?=;)

Thx @wiktor-stribiżew

  • Related