25
Views
4
Comments
Solved
how to match but not capture part of a regex
Question
Application Type
Reactive

Hello,

I am using the Regex_Search Server Action with the pattern "BGA\D*(\d+)". 

It returns the matched string correctly, but I want only the "captured group" i.e. only the number, without the string containing "BGA" before it.

Is it possible?

Many thanks

Alain

2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

Hi @Alain Cuvillier ,

you could switch to the RegexMatch action of this forge component, it will give back a group of results, the whole matched string and also each capturing group you defined.

Dorine

2019-11-11 17-10-24
Manish Jawla
 
MVP

Hi @Alain Cuvillier ,

There are couple of methods you can use to get that string and most simple one is you can use string replace method() and search your string which you want to replace & replace it with empty "" string and you will get the number as output.


there are other options are well

https://success.outsystems.com/documentation/11/reference/outsystems_language/logic/built_in_functions/text/#Replace 

It totally depend upon your string format which one works best for you.

Regards,

Manish Jawla

UserImage.jpg
Alain Cuvillier

Hi Manish ,

my strings are like this:

TFBGA 292 

TFBGA-290

BGA_200 

I don't know what to expect between the "BGA" part and the number. 

I don't see how to use the Replace() or the String_Split.

Or I am missing something?

2019-11-11 17-10-24
Manish Jawla
 
MVP

Hi @Alain Cuvillier ,

As I said it always depend upon your string format. I have created a sample app for you. please check that.

If you always looking for 3 digit numbers in the end of your string you can easily get it by using substr() method. Please check the attached oap.

Thanks,

Manish Jawla

StringDemo.oap
CustomRegex.gif
2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

Hi @Alain Cuvillier ,

you could switch to the RegexMatch action of this forge component, it will give back a group of results, the whole matched string and also each capturing group you defined.

Dorine

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.