Jump to content
Server Maintenance This Week. ×

Get Text left of , and right of ,


MacFileman

This topic is 1198 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Sorry... I am sure this calculation is in the forum somewhere and it's super simple.

Sample Text: 123 Main Street, Boston

Need the copy to the left of the comma..and then the copy to the right. 

I think its a LEFT calculation...?

Link to comment
Share on other sites

2 minutes ago, MacFileman said:

Need the copy to the left of the comma..and then the copy to the right. 

The following calculation will return the text before the first comma:

Left ( text ; Position ( text ; "," ; 1 ; 1 ) - 1 )

Note that this assumes the given text does contain a comma - otherwise the result will be empty.


To extract the text after the first comma, you can use:

Right ( text ; Length ( text ) - Position ( text ; "," ; 1 ; 1 ) )

Note that "text after the first comma" includes the space immediately following the comma; if you don't want that, subtract 1 from the calculated position.


Alternatively you could start by substituting the comma with a carriage return, then use the GetValue() function to retrieve one of the resulting values. This is often a convenient shortcut - but it's usefulness is limited to specific cases. If you want to be able to parse any text, I recommend getting familiar with the basic method using Left(), Right(), Middle(), Position() and Length() functions.

 

 

 

  • Like 1
Link to comment
Share on other sites

This topic is 1198 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.