IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Regular Expression in FlexText Options · View
coleborn
Posted: Tuesday, May 26, 2015 3:25:16 PM
Rank: Member

Joined: 5/26/2015
Posts: 10
Location: United Kingdom
Hi,

I'm trying to use a regular expression in my flextext file to split a value after the 3rd pipe ( | )

I am using the split once function but can't get it to function as i need:

example

input file
value1|value2|value3|value4|value5|value6|value7

Expected first output
value1|value2|value3

Second Output
value4|value5|value6|value7

Any help appreciated
island
Posted: Wednesday, May 27, 2015 10:14:05 AM
Rank: Newbie

Joined: 10/28/2002
Posts: 1,283
Location: AT
Hi,

try this:

Code:

([^/|]*[/|]){3}
coleborn
Posted: Wednesday, May 27, 2015 11:40:09 AM
Rank: Member

Joined: 5/26/2015
Posts: 10
Location: United Kingdom
Hi Island,

Thanks for the suggestion, however Mapforce doesn't keep the start of the string.

You can see in the second screenshot the sample text of "Store" is blank









Regards

Graham
island
Posted: Thursday, May 28, 2015 6:23:14 PM
Rank: Newbie

Joined: 10/28/2002
Posts: 1,283
Location: AT
Yes you are right.

At the moment I am unsure what the correct regular expression would be to match only the 3rd occurrence of the pipe character in the string, but in the absence of a regular expression you could always split the line three times and store the value each time (see attached flextext).


File Attachment(s):
MapForceFlexText1.zip (1kb) downloaded 647 time(s).


coleborn
Posted: Wednesday, June 3, 2015 9:16:24 AM
Rank: Member

Joined: 5/26/2015
Posts: 10
Location: United Kingdom
Thanks, this works but its a shame its not as clean as the regular expression option.
vlad
Posted: Wednesday, June 3, 2015 9:41:45 AM
Rank: Advanced Member

Joined: 12/13/2005
Posts: 2,856
Location: Mauritius
The regular expression syntax simply doesn't allow to count occurrence, therefore it doesn't work. The attempt with ([^/|]*[/|]){3} doesn't work either because it declares the whole start of the string as a one big splitter, which is why it "gets lost" - what you get is everything before (empty string) and everything after.
coleborn
Posted: Thursday, June 4, 2015 11:34:54 AM
Rank: Member

Joined: 5/26/2015
Posts: 10
Location: United Kingdom
Perhaps a possible improvement for future release would be an option to store the splitter value too.

Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.