【问题标题】:Regex to remove first two characters of a string if they are alphabets正则表达式删除字符串的前两个字符(如果它们是字母)
【发布时间】:2022-12-04 12:00:40
【问题描述】:

My client uses SKUs from which they change the first two digit suffix to represent changes/updates in models. As an analyst, I need to make a unique list of SKUs to use in my data studio dashboard. A sample of the SKUs would look like:

NP9151BM01
NL9151BM01
NL6004SL01
NN6004SL01
NP1927YM05
NN1927YM05
NQ1296BM01
NG1296BM01
NQ1044YL04
NN1044YL04
NP9151YM05
9151YM05
1044YL04

I need to use regex to check if the first two characters are alphabets and remove them if they are. For example, if I have NP9151BM01 and NL9151BM01 as SKUs, I need to remove NP and NL from them to end up with the exact same SKU. However, if I have 9151YM05 or 1044YL04 as SKUs, I need to keep it as it is.

For my solution, I have researched on google and stack overflow and I\'ve found this regex (?<=^..).*$ which will remove the first two characters in all SKUs but I\'m not sure how to customise it to only remove the first two characters if they are alphabets.

I would appreciate any help that I can get with this!

    标签: regex google-sheets google-sheets-formula


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 2017-11-26
    • 2015-09-07
    • 2018-01-16
    • 2022-10-12
    • 2012-01-10
    • 1970-01-01
    • 2017-06-20
    • 1970-01-01
    相关资源
    最近更新 更多