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

Question

Question

Regular expression - Stop part way through text

asked on February 18

I have this formula EEC001\s*(.*)\s*(?=\s+[A-Z]+\s)

I am getting this as a result.

EECOL ELECTRIC CORP    CANOE PROCUREMENT

Original text is 
    EEC001         EECOL ELECTRIC CORP    CANOE PROCUREMENT GROUP  

How can I just pull the EECOL ELECTRIC CORP?

I thought perhaps I could limit it to the number of characters, but I am not sure how to write that. I am still learning.    

0 0

Replies

replied on February 18

In your example you gave, I see a lot of whitespace proceeding what I'm assuming is the account number, is that correct?

In the response above you mentioned the company name may begin with a number, if so, using the following regex will capture the second column of data with or without a preceeding number in the company name:

^\s+\S+\s+([\dA-Z][A-Z\d\s]+?)\s{2,}

You can see it in action here:
https://regex101.com/r/JPasaR/1

1 0
replied on February 18

Hi Mary Lou, 

Try this regex:

\s{2,}([A-Z\s]+?)\s{2,}

This regex will work with this string of data. Is the other text formatted the same way?

0 0
replied on February 18

Occasionally, the company name begins with a number.

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

Sign in to reply to this post.