0

I have a table with Equipment column containing strings. I want to split string, take a part of it and add this part to a new column (SerialNumber_Asset). Part of the string i want to extract always has the same pattern: A + 7 digits. Example:

       Equipment                                   SerialNumber_Asset
1      AXION 920 - A2302888 - BG-ADM-82 -NK        A2302888 
    
2      Case IH Puma T4B 220 - BG-AEH-87 - NK       null
    
3      ARION 650 - A7702047 - BG-ADZ-74 - MU       A7702047 
    
4      ARION 650 - A7702039 - BG-ADZ-72 - NK       A7702039 

My code:

select x, y, z,
regexp_extract(Equipment, r'([\A][\d]{7})') as SerialNumber_Asset
FROM `aa.bb.cc`

The message i got:

Cannot parse regular expression: invalid escape sequence: \A

Any suggestions what could be wrong? Thanks

1 Answer 1

1

Just use A instead of [\A], check example below:

select regexp_extract('AXION 920 - A2302888 - BG-ADM-82 -NK', r'(A[\d]{7})') as SerialNumber_Asset
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.