Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 views
in Technique[技术] by (71.8m points)

text extraction - Extract Substring separated by similar delimiters MYSQL

I have a Mysql Table with a column called ACCOUNT_NUMBER that includes a transaction number I need to extract:

ACCOUNT_NUMBER
MB-MuchBetterDeposit-230-337882630--
CallCard-BankDeposit-350-337887834--
RealPay-Deposit-108-337894920--
PayMathod-WebDeposit-2-339163798--PAYMETHODAR

To extract the 9 figures number located between the delimiters '-' and '--' I use this in my query:

SUBSTR(ACCOUNT_NUMBER FROM ( locate('--',ACCOUNT_NUMBER)-9) FOR 9)

Which returns the value (337882630,337887834, etc...). Now, if I imagine that the length of the Tx will be increased in time from 9 to 10 or 11 figures, what would be the solution to accurately extract this Tx? I tried with locate but it gets messed up since '-' and '--' are very similar.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...