Start a new topic

Need RegEx for first letter in a string equals "A"

Does anyone know of a regular expression that will identify the first letter of a string? I would like to return a value for each appeal code that begins with the letter "A" and a different value for appeal codes that begin with a different letter. ~Bill
1 Comment

Hello Bill!

I recently created a similar dictionary for someone who wanted to assign the Canadian province based on the first letter of the postcode. The only variable I could see would be the string length of your appeal ID's. In this example, you will see that any postcode starting with the letter "A" or "a" will return the value of "NL" (Newfoundland). You may need to adjust the number in the french brackets to account for your total string length. Also, this formula works best when there are no spaces in the string for Value to Match on, which I handled in the example below by first replacing the space [ ] with -BLANK-.

The basic Regular Expression formula would work something like this:

 

Replacement Value: NL

Value to Match On: ^([Aa]\w+)\S{3}$

 

Replace the "NL" with your desired final result returned based on that first letter and adjust the {#} as needed. Hope this helps!

 

image

Canadian Province from Postcode.xlsx

 

 

Allison B.

 

Login or Signup to post a comment