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

Question

Question

I am looking for a regular expression to populate a location token from a documents file path.

asked on February 3, 2014

How do I extract the word florida from the following text using a regular expression.

 

c:\florida\new document\

 

Thanks

0 0

Replies

replied on February 3, 2014 Show version history

Something like this should work:

 

(?<=\\)(florida)(?=\\)

 

Note the lookahead and lookbehind to ensure that there are slashes on either side. You should be able to edit that to ensure it's at the position in the path that you want.

 

The above example will match anywhere in the path.

 

It appears that your example is a bit sanitized. Are you in fact looking to find the any paths that have a florida folder, or are you looking for a list of folders that are in the root of c:? A little more detail on what you are trying to accomplish will make the answers fit what you need much better.

0 0
replied on February 4, 2014

Thank you for your response.

 

I am trying to create a token based on a customers location from the file path of a document I am importing.

 

c:\incoming documents\01 corporate\doc type 1

 

I have a root folder called incoming documents and a sub folder for each location (01 corporate, 02 branch 1, etc) Each location also has sub folders for each document type ( invoices, cheques )

 

I am looking to capture the 01 corporate text for the token.

 

 

 

 

0 0
replied on February 4, 2014

Something like \\[^\\]+\\([^\\]+) (ie, the second group of characters that are not slashes) should do it.

 

(The slash is a special character, so it needs to be "escaped" to be treated as a literal slash. The escape character is the slash, so that why they're always appearing in sets of 2.)

0 0
replied on February 4, 2014 Show version history

Given: c:\incoming documents\01 corporate\doc type 1

Assuming: using workflow and tokens

 

  • Get "incoming documents\01 corporate\doc type 1"
    • c\:\\(.+)

Use that to get the value after the 'C:\' and be left with the rest. 

 

If we have that in a token, then you can easily use the Token Editor to "Apply Function" called "Split" and set it to split the input into a multi-value token for each '\' it encounters and then you can use the "Apply Index" capability to get the index of what you wanted.

 

 

Indices:

  1. incoming documents
  2. 01 corporate
  3. doc type 1

 

 

You can set tokens to each of these values to use as you need them.

3 0
replied on August 9, 2015

Thanks Kenneth for the tip on the Apply Function and Apply Index options in the above post. I needed to extract 'Finance' from the folder path 'LaserRepository\Finance\Invoices\Paid'. I used the Split function together with Apply Index and used the value at index 2.

0 0
replied on February 3, 2014

Well, for the text provided, you could use @"c:\\(\w+)\\*" (I'm assuming .net style regexes), which will have "florida" as its first match group, but that might not work in all cases that you intend to use it in. Is the string of interest always the first folder past c:\? Will the value ever have spaces in it? In order to write a regular expression that covers all of your cases we need a better explanation of the problem.

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

Sign in to reply to this post.