You are viewing limited content. For full access, please sign in.

Question

Question

rearrange date in pattern match

asked on November 18, 2014

i am trying to do a regex match agains the full document text but need to rearrange the order. i have tried using named groups  and then back references \k<> but i cant get it to work at all. is there a way to do this all in the token editor. or do i need to make multiple tokens and then reorder them in another step  

 

i have a date in the full text but its in the wrong order to store it in the date field  

0 0

Replies

replied on November 18, 2014

i think your prompt is a bit confusing. 

 

Are you saying you have a date in a token, but it is not in the proper MM/dd/yyy format for a date metadata field? We can fix that.

 

What format is it in?

0 0
replied on November 18, 2014

It sounds like that's what Joel is asking. I don't know of a good way to do this all in a single Assign Tokens or Pattern Match activity. Laserfiche just uses Microsoft's .NET style regular expressions, but I don't believe there is any support for the "replacement" features within the token dialog. (You could use those options within some kind of .NET script if you chose). I think your best bet to make a workflow that is understandable and easy to maintain is to rearrange the date by using multiple tokens and piecing them together.

Of course, there are ways to do it, if you really want to force things without any regard to how clumsy the expressions will get. For instance, the first option I thought of was that you could use a pattern match where the input is your date token duplicated as many times as necessary, and then you could use capture groups to pick off the pieces in a new order.  Say you had dates in dd/mm/yyyy format and wanted to switch the day and month. You could use "%(your_date)%(your_date)" as input, and then match this with something ugly like "\d{2}/(\d{2}/)\d{4}(\d{2}/)\d{2}/(\d{4})" which just picks off the groups you want in the new order. Again, I would strongly recommend against this because it would probably be terrible to try and figure out why/how this all works if you come back to the workflow several months later for some reason.

replied on November 18, 2014

the date is in the full text of the document. i am pattern matching to find it and then drop it in a field. its like yyyy/mm/dd and i need to move those around to match our standard. so i want to grab three groups in the pattern match but then reorder them i have seen on regex sites $1 $3 $2 or ${1} used where you can place the groups in a new order. 

0 0
replied on November 18, 2014

Should be able to modify the token in the token editor with the "Apply Formatting" set to "MM/dd/yyy" and it works in my testing.

1 0
replied on November 18, 2014

Yep... taking down my original post because I totally forgot about this feature. Definitely the way to go..
 

0 0
replied on November 18, 2014

to put it simply i need to take yyyy/mm/dd out of the full text and then have it be yyyy/dd/mm when i place it into a metadata field. but as cleanly as possible, because i will need to do it in alot of places.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.