How to get a particular numbers by Regex

Hi,
I need to get the Bold numbers from the last line by using regex.

2749
56
42
35

                    Statistik nach Abteilungen   vom 06.05.24 bis 12.05.24                                       Datum 13.05.24

  Abteilungen  !    Soll !    Ist         ! FG 1: K     ! FG 2: B     ! FG 3: KU    ! LA1:        ! LA2:        ! Sonst. FG   !
  -------------+---------+----------------+-------------+-------------+-------------+-------------+-------------+-------------+
   1110        !      75 !      75 100,0% !    35  46,7%!         0,0%!         0,0%!         0,0%!         0,0%!    40  53,3%!
   1400        !      40 !      40 100,0% !         0,0%!         0,0%!         0,0%!         0,0%!         0,0%!    40 100,0%!
   1530        !      70 !      73 103,8% !         0,0%!         0,0%!         0,0%!         0,0%!         0,0%!    28  40,0%!
   1800        !      95 !      98 102,9% !         0,0%!         0,0%!         0,0%!         0,0%!         0,0%!    54  56,8%!
   2200        !     145 !     145 100,2% !         0,0%!         0,0%!         0,0%!         0,0%!         0,0%!    82  56,6%!

  -------------+---------+----------------+-------------+-------------+-------------+-------------+-------------+-------------+
  Gesamtsumme !    **2749** !    2786 101,3% !    **56**   2,0%!    **42**   0,0%!    **35**   1,3%!         0,0%!         0,0%!  1708  62,1%!

Hi @Prasaanth_S2

Can you specify the input and expected output seperately.

Regards

Hi, the input is like in the image and the output I expect is
2749
56
42
35

Hi,

How about the following pattern?

(?<=\*\*)\d+(?=\*\*)

Regards,

1 Like

Hi @Prasaanth_S2

Try this:

((?<=Gesamtsumme.*\!\s*)\d+(?=\s*\!))|((?<=\!\s*)\d{2}(?=\s*\d{1}\,\d{1}\%))

Regards

we assume that ** is coming from the Bold formating in the Editor and is not contained in the original data, right?

With a Line split and filtering we can isolate the TotalSum Line
With an optimistic Regex we can extract too much:


and then filter on the occurence position on what we want to grab

hi, the ** comes as I applied for Bold format to identify, sorry for my miss communication

Another strategy could be to use the position from the +

as a column seperator mark and split out the values of interests

Hi @Prasaanth_S2

The below regex should help you.

(?<=\*\*)\d+(?=\*\*)

Assign activity -> str_Text = "Statistik nach Abteilungen   vom 06.05.24 bis 12.05.24                                       Datum 13.05.24

  Abteilungen  !    Soll !    Ist         ! FG 1: K     ! FG 2: B     ! FG 3: KU    ! LA1:        ! LA2:        ! Sonst. FG   !
  -------------+---------+----------------+-------------+-------------+-------------+-------------+-------------+-------------+
   1110        !      75 !      75 100,0% !    35  46,7%!         0,0%!         0,0%!         0,0%!         0,0%!    40  53,3%!
   1400        !      40 !      40 100,0% !         0,0%!         0,0%!         0,0%!         0,0%!         0,0%!    40 100,0%!
   1530        !      70 !      73 103,8% !         0,0%!         0,0%!         0,0%!         0,0%!         0,0%!    28  40,0%!
   1800        !      95 !      98 102,9% !         0,0%!         0,0%!         0,0%!         0,0%!         0,0%!    54  56,8%!
   2200        !     145 !     145 100,2% !         0,0%!         0,0%!         0,0%!         0,0%!         0,0%!    82  56,6%!

  -------------+---------+----------------+-------------+-------------+-------------+-------------+-------------+-------------+
  Gesamtsumme !    **2749** !    2786 101,3% !    **56**   2,0%!    **42**   0,0%!    **35**   1,3%!         0,0%!         0,0%!  1708  62,1%!"

=> Use Find Matching Patterns activity and configure the below way and store the output.

=> Run a For Each loop to iterate through Matches

For Each currentMatch in Matches
   Write Line -> currentMatch.ToString
End For Each

Output:
image

Regards

Hi,

Can you try the following sample? This extracts all the value in line of Gesamtsumme and we can get any columns value like m.Group(“SOLL”).Value

 m = System.Text.RegularExpressions.Regex.Match(yourString," Gesamtsumme.*?!\s*(?<SOLL>\d*)\s.*?!\s*(?<IST>\d*)\s.*?!\s*(?<FG1>\d*)\s.*?!\s*(?<FG2>\d*)\s.*?!\s*(?<FG3>\d*)\s.*?!\s*(?<LA1>\d*)\s.*?!\s*(?<LA2>\d*)\s.*?!\s*(?<SONST>\d*)\s")

Sample
Sample20240629-1a.zip (3.1 KB)

Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.