Take out value form variable matchcollection

studio
variable

#1

Hi,

I have been created variable type matchcollection where i got 3 column: First, Secend and Third. But i dont know how to take out one of the column. Can you guid me… the name of variable “x” so i need x… and what next to take out for example column first ?

Many thanks for help,
Regards,
@fudi5


#2

matchcollection(0).ToString(), matchcollection(1).ToString(), matchcollection(2).ToString()

Regards,
Arivu


#3

Hi @arivu96,

It dosen`t work. I got mesage: “Write line : Specified argument was out of the range of valid values.
Parameter name: i”

Regards,
@fudi5


#4

Hi @fudi5,

how you used can you send the screenshot.

make sure the matchcollection should not be empty.

you can check using if condition matchcollection.Any
True->values available
False-> No data in the matchcollection.

matchcollection.count -> you will get the collection data count.

Regards,
Arivu


#5

@arivu96,

Im doing this:

1.windows assign
(x is variable matchcollection and
row(sekcja) looks like this:

3 10,11 1 -

)

system.Text.RegularExpressions.Regex.Matches(row(“sekcja”).ToString,"^(?<FIRST>(?:/\s)?(?:\w+(?:,\s\w+))|—)\s(?<SECOND>(?:/\s)?(?:\w+(?:,\s\w+))|—)\s(?<THIRD>(?:/\s)?(?:\w+(?:,\s\w+)*)|—)$")

  1. writeline
    x(0).tostring

Regards,
@fudi5


#6

Hi @fudi5,

can you tell me what value you will get??? in row("sekcja").ToString

Regards,
Arivu


#7

Here:


#8

i think no data match based on your regex pattern.

Use this link to test the regex pattern
https://regex101.com/

Regards,
Arivu


#9

Ok i know what can be wrong. Many thanks for help.

I`ll let know.

Regards,
@fudi5


#10

I have been changed patter and now it take this case but still dosent work:

^(?(?:/\s)?(?:\w+(?:,\s\w+))|—)\s(?(?:/\s)?(?:\w+(?:,\s\w+))|—)\s(?(?:/\s)?(?:\w+(?:,\s\w+)*)|—)$


#11

Hi @fudi5,
For testing regex pattern use the below link.
https://regex101.com/

Regular Expression : ->your regex pattern
Test String -> you input

Regards,
Arivu


#12

@arivu96
I tested it before you sent link.

Now its working fine i just changed pattern.

Regards,
@fudi5


#14

This is SOLUTION:
system.Text.RegularExpressions.Regex.Match(row(“sekcja”).ToString,"
(?(?:/\s)?(?:\w+(?:,\s?\w+))|—)"+
“\s”+
"(?(?:/\s)?(?:\w+(?:,\s?\w+)
)|—)"+
“\s”+
“(?(?:/\s)?(?:\w+(?:,\s?\w+)*)|—)”)