Skip to main content
4-Participant
October 10, 2025
Question

How to use regular expression in queryspec search condition.

  • October 10, 2025
  • 4 replies
  • 403 views

I have requirement to search object using queryspec which can have number with leading zero(to make it 8 digit length) or without leading zeros.

e.g. I am to search object number 66, query should be able to find object 66, 066, 0066 etc. I got regular expression to search( ^0*66$ ) need to know how to use in queryspec.

4 replies

Fadel
23-Emerald I
October 10, 2025
Catalina
Community Moderator
October 21, 2025

Hi @Gajendra 

I wanted to see if you got the help you needed.

If so, please mark the appropriate reply as the Accepted Solution or please feel free to detail in a reply what has helped you and mark it as the Accepted Solution. It will help other members who may have the same question.

Of course, if you have more to share on your issue, please pursue the conversation.

Thanks,

Catalina | PTC Community Moderator
13-Aquamarine
October 24, 2025

Try this

 

// Constant expression using LIKE pattern to match leading zeros
ConstantExpression ce = new ConstantExpression("%66"); // matches 66, 066, 0066, etc.
ce.setUseEscape(true);

// Create search condition
SearchCondition sc1 = new SearchCondition(ca, SearchCondition.LIKE, ce);

Gajendra4-ParticipantAuthor
4-Participant
October 30, 2025

Hi,

Thank you for the reply. %66 will also match to 166, 266 or any number with trailing 66? My requirement is get number 66 or with leading zeroes.

HelesicPetr
22-Sapphire II
22-Sapphire II
November 5, 2025

Hi @Gajendra 

Generally, queryspec does not support regular expressions. You have to combinate the substitute sql characters as "_" for one character or "%" for multiple characters. 

PetrH

PetrH