0

See below string we have in document

    32Main Section
    32.1Assignment and transfers by Obligors
    32.2Additional Borrowers
    (a)Subject to compliance with the provisions of paragraphs (c) and (d) of Clause 28.10 ("Know your customer" checks),

Output Expected (List string only if they have this xx.xx pattern at the start of the line)

32.1Assignment and transfers by Obligors
32.2Additional Borrowers

Regex we are trying \d+(\.\d{1,2}.*)

But this gives us 3rd line also which we dont have as it has number in the middle of line. We want to list only lines which start with the number or decimal...

user3657339
  • 607
  • 2
  • 9
  • 20

2 Answers2

0

You can try this mate

^\d+\.\d+.*

Explanation

  • ^ - Anchor to start of string.
  • \d+\.\d+ - Matches xx.xx pattern (x is number).
  • .* - Matches anything except newline. zero or more time (greedy mode)

Demo

Code Maniac
  • 37,143
  • 5
  • 39
  • 60
0

You want to match any string starting with a digit, so ^\d+(?:\.\d{1,2})?.* that can be shortened to ^\d.* will do the job.

A better idea is to specify a delimiter for the number. Say,

^\d+(?:\.\d{1,2})?[ .].*
                  ^^^^

Or make sure there is no digit:

^\d+(?:\.\d{1,2})?(?!\d).*
                  ^^^^^^

The [ .] will require a space or . after the initial number.

Details

  • ^ - start of a string
  • \d+ - 1+ digits
  • (?:\.\d{1,2})? - an optional non-capturing group
    • \. - a dot
    • \d{1,2} - 1 or 2 digits
  • [ .] - a space or .
  • .* - the rest of the string.
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563