Four Stars

tFilterRow regex not working?

I'm using the advanced setting in tFilterRow (Open Studio 6.3). I've tried the following code (regex) to filter rows:

java.util.regex.Pattern.compile("\\d+").matcher(input_row.code).find()

java.util.regex.Pattern.compile("\\d*").matcher(input_row.code).find()

java.util.regex.Pattern.compile("[0-9]+").matcher(input_row.code).find()

java.util.regex.Pattern.compile("[0-9]*").matcher(input_row.code).find()

 

This should return only records where the value of "code" only exists out of digits (0-9), however it does return records with at least one digit and characters. Which regex should I use to return only digit values?

1 ACCEPTED SOLUTION

Accepted Solutions
Six Stars

Re: tFilterRow regex not working?

One last try for me
input_row.code.trim().matches("[0-9]+")
10 REPLIES
Moderator

Re: tFilterRow regex not working?

Hi,

Could you please elaborate your case with an example with input and expected output values?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Four Stars

Re: tFilterRow regex not working?

Hello Sabrina,



Thnx for your reply, here's my case. It should only return rows that exists only out of digits (in schema this is column "code" that refers to column K "AUTHORISATIE" in the csv file). It now returns 303 out of 305 records because the value contains a digit, it should return only 40 records (eg in the csv file row K7 which has a value of 113577)



[cid:image002.png@01D34981.D6D5C8E0]



[cid:image004.jpg@01D34982.BA72D3E0]



[cid:image007.jpg@01D34982.BA72D3E0]



With regards,



Remco


Moderator

Re: tFilterRow regex not working?

Hello,

Actually, we cannot see your image from our side. Could you please check it?

Could you please  upload your Screenshots by click 'photos' icon on forum? Feel free to let us know if there is any problem for you.

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Four Stars

Re: tFilterRow regex not working?

Hello Sabrina,

 

Here are the screenshots

 

nov1.pngnov2.jpgnov3.jpg

 

Remco

Six Stars

Re: tFilterRow regex not working?

Can you try any of below expressions?
java.util.regex.Pattern.compile("^[0-9]+").matcher(input_row.code).find()

Or
java.util.regex.Pattern.compile("^\\d+").matcher(input_row.code).find()
Four Stars

Re: tFilterRow regex not working?

This doesn't work, it returns 0 records.



Thnx Remco


Six Stars

Re: tFilterRow regex not working?

Sorry use matches() method instead of find()

java.util.regex.Pattern.compile("[0-9]+").matcher(input_row.code).matches()

Or
java.util.regex.Pattern.compile("\\d+").matcher(input_row.code).matches()
Four Stars

Re: tFilterRow regex not working?

Also 0 records...



Remco


Six Stars

Re: tFilterRow regex not working?

One last try for me
input_row.code.trim().matches("[0-9]+")
Four Stars

Re: tFilterRow regex not working?

That did it for me!!!



Thnx.



Remco