Jump to content
Changes to the Jaspersoft community edition download ×

Filter a field using character mask


renatomitsunami

Recommended Posts

Hi..I'm trying to use a mask filter in a field, like this example:

                   Name                   Ticket
John123456/2017
Mary564587/2017
Anthony698/2017
Peter1356/201

After apply mask filter in "Ticket" field, the expected result is:

                   Name                   Ticket
John123456/2017
Mary564587/2017

Ticket field with "######/####" format.

How can I apply this filter ?

Thanks.

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Hi PEichelberg,

I need to count the numbers of occurences in correct pattern format "XXXXXX/XXXX" = (6 characters before "/" and 4 characters after "/")

>>  IF $F{Ticket} contains a string with correct format THEN 1....Else 0.

In this example, 2 corrects rows:

                   Name                   Ticket
John123456/2017
Mary564587/2017

 

Thanks again

Link to comment
Share on other sites

Hi PEichelberg,

I need to count the numbers of occurences in correct pattern format "XXXXXX/XXXX" = (6 characters before "/" and 4 characters after "/")

>>  IF $F{Ticket} contains a string with correct format THEN 1....Else 0.

In this example, 2 corrects rows:

                   Name                   Ticket
John123456/2017
Mary564587/2017

 

Thanks again

Link to comment
Share on other sites

  • 2 weeks later...

Okay ... so basically you want to only display those $F{Ticket} that match your format of ######/#### and hide every other one ...

 

So what you need to do is get your data as usual but then in the Dataset and Query Dialog go to tab Filter Expression.

 

Put $F{Ticket}.matches(REGEX) == true there. Or == false. I'm currently not sure which one would help actually :D

 

REGEX should be a String pattern like this: d{6}/d{4}

 

You can check the meaning of this at https://regex101.com/ as I did too. Basically that regex checks if you've got a string that has six digits, a slash and four further digits. If so, the regex says your string is valid. As I said, I don't know if you need to say == true or == false in FilterExpression, but you can figure that out easily.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...