简体   繁体   中英

I want to use regex to extract nine digits from a string in Blueprism

I have the following string:

ABCD/SESSION REMARKS/SESSION REMARKS_002FT2213700215_ /CODTYPTR/049 //R101841246/058  Session 220517080                                                  REF: 02024741031486605002FT221

And i want to extract the nine digits that from "R101841246".

I have tried using Extract Regex in Utility - Strings of Blueprism , using the regex pattern (?<Lower>\d{9}) but the code is extracting 221370021, the first nine digits from SESSION REMARKS_002FT2213700215_ .

I need a regex that will strictly extract nine consecutive digits and ignore occurrences where there is over nine digits

here is one way do it

(?<=\/\/).(\d){9}(?=\/)

https://regex101.com/r/TYnSuP/1

(?<=//): look behind for //
. : then any character
(\d){9}: capture the 9 digits
(?=/): and lookahead /

You can use

\bR-?(?<Lower>\d{9})\b

Here, it matches

  • \b - a word boundary
  • R - an R letter
  • -? - an optional hyphen
  • (?<Lower>\d{9}) - nine digits captured into Group "Lower"
  • \b - a word boundary.

See the regex demo .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM