Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Dynamic Regex in tExtractRegexFields

My job is
tJavaRow ------>  tExtractRegexFields
I check some condition in tJavaRow and set the regex value to output_row.RegexPattern and try to access it in tExtractRegexFields in Regex property like input_row.RegexPattern, but I am getting null value. I don't understand why regex value is not getting set. In short, I want Regex property of tExtractRegexFields dynamic.
Please help me on this.

Labels (2)
9 Replies
Anonymous
Not applicable
Author

hi

you right, tJavaRow use the syntax input_row & output_row ... but in other component use nameofRow.nameofField (ex : row1.RegexPattern)

hope it helps

regards
laurent
Anonymous
Not applicable
Author

Thanks.
I tried it but no luck. Actually If I put static regex pattern it works, but when I try dynamic regex then it fails. Even I tried to set regex in global map at start and tried to use it in regex field but it didn't work.
Anonymous
Not applicable
Author

the regex doesn't match what you expect or you've an error?
what's one of your regex are trying to play ?

regards
Anonymous
Not applicable
Author

When I put the hard coded regex pattern in Regex field of tExtractRegexField then it works fine and same regex pattern
When I set in context or global map and try to get the regex pattern in tExtractRegexField ((String)globalMap.get("regex_pattern")) then I get null pointer exception.
Anonymous
Not applicable
Author

if you compare (String)globalMap.get("regex_pattern") & hard coded pattern, are they the same ? (use a System.out.println() to log value from globalmap).
I suspect some backslash added or those kind of things that escape special caracters.

Can you post your regex & a sample of your data input ?

regards
Anonymous
Not applicable
Author

Yes I ensured that both patterns are same
Anonymous
Not applicable
Author

so the only reason is that your var (String)globalMap.get("regex_pattern") = null when you're trying to use it.
Anonymous
Not applicable
Author

Yes. My job flow is :-
tFileInputSendMail  ->  tJava -> tExtractRegexField
In tJava, I set the regex pattern to variable (MyRegex.regex = "regex pattern") and try to use it in tExtractRegexField (MyRegex.regex), I get it null.
When I move tJava before tFIleInputSendMail then it works fine. As per code, I can see regex compilation happens before value is set to variable.
Anonymous
Not applicable
Author

tjava cannot manage flow (MyRegex.regex ) => use tjavarow for that or initialize a global var : globalMap.put("regex',"regex pattern")
& use it with (String)globalMap.get("regex")