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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
mobmsc2
Creator
Creator

Regex extract 2 values (dates) from string using tExtractRegExFields

I could do with some help with tExtractRegexFields from the community. Given the string below

some text to begin with Start Date : '01-SEP-2016' , End Date : '30-SEP-2016'. Download 30-SEP-16

I want to extract Start Date and End Date values. I have the following RegEx

"(\\d{2}-\\D{3}-\\d{4})"

which will extract "a valid value" but doesn't extract both dates (I'm doing further processing to get the download date). My output schema is a generic schema of 2 nullable strings but only the 2nd value is extracted and stored in the 1st schema position. 

 

When I use http://regexr.com/ and remove the escape "\" chars the regex above  becomes

(\d{2}-\D{3}-\d{4})

and will highlight both matching dates which seems to imply the regex is valid for both date values, it just won't extract both values.

Can anyone provide me with some pointers to capture the 1st and 2nd dates and store them in the correct positions in the output ?

Labels (2)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

Hi,

Define the tExtractRegexFields schema as:

0683p000009LuMt.png

and the regex as:

"(^.*)(\\d{2}-\\D{3}-\\d{4})(.*)(\\d{2}-\\D{3}-\\d{4})(.*$)"

Here is the result from tLogRow:

0683p000009LuOt.png

Hope this helps,

 

View solution in original post

4 Replies
mobmsc2
Creator
Creator
Author

The following regex strings either generate an error or don't extract both dates

"(\\d{2}-\\D{3}-\\d{4}).(\\d{2}-\\D{3}-\\d{4})"
"\\+(\\d{2}-\\D{3}-\\d{4})"
"(\\d{2}-\\D{3}-\\d{4})//g"
TRF
Champion II
Champion II

Hi,

Define the tExtractRegexFields schema as:

0683p000009LuMt.png

and the regex as:

"(^.*)(\\d{2}-\\D{3}-\\d{4})(.*)(\\d{2}-\\D{3}-\\d{4})(.*$)"

Here is the result from tLogRow:

0683p000009LuOt.png

Hope this helps,

 

mobmsc2
Creator
Creator
Author

Thanks the 

.*

you had inside the capture group to extract the middle text (which I'm reading as zero or more characters) was what I needed followed by the Date extractor again which gave me

"(\\d{2}-\\D{3}-\\d{4}).*(\\d{2}-\\D{3}-\\d{4})"
cterenzi
Specialist
Specialist

Well that escalated quickly.  I missed three replies while typing my own!