Cuting match text


#1

Hi Guys,

I got question im using regex.ismatch to check part of string… but if i got result true… how can i cut out this part of string ?

Many thx for help.
Regards,
@fudi5


#2

Hi Piotr,

The activity Programming - String - Is Match indicates whether the specified regular expression finds a match in the string, the result you are getting :slight_smile:
To remove the parts that matches the regular expression, use the Replace activity found in the same location, Programming - String.

There is another one, Matches, that will return all the successful matches in the string.

Regards
Silviu


#3

Hi @Silviu

Yep i know that and this is my main problem… because i dont want remove(replace) matched string… i want remove(replace) unmatched string. For more be specific i want replace everything but not matched part:)

Maybe there is some negation for whole pattern? Then it will be help…

Many thanks for answer :slight_smile:
Regards
@fudi5


#4

How about using the Matches activity and then join all match values in a new string.
Matches return a list of Match objects and each one contains a string value (accessible either with the Value property or ToString method).


#5

@Silviu,
Can i make negation of pattern ?

I got something like this 3 column where i got patter which pointing every time on secend column:
3,3 — 133
577 — 23, 3
3 — ---
3 — 3
5 — sdusahdydgf dsdsd fdfd
2 3 ddsadsada

Thats why i can use split and i can receive 1 and 3 column but i need cut out 2 column :slight_smile:
Maybe that post clear air :wink:

Solution:

(^\d*[,]?\s?\d?\s?(?=\d|[-]{3}))|((?<=\d\s\d\s).*|(?<=[-]{3})\s.*)


#6

Hello Fudi5,

Could you please explain more on the solution? Looks like this solution is static not dynamic.
Will this solution work if we change the sample values? What I understand from your post initially is you are looking for substring for NOT matching string.

For Eg. If you string is "FutureIsAutomation’ and you search for “Is” then you need “FutureAutomation” as answer.

Please confirm.


#7

Hi @pawanbag,

I think its dynamic solution because values from start and end are changing.
Here you got some cases:

53, 63, 53 (—) 2
41 (135, 153, 231, 2311) 133
43 (455222) dfg
4 (5554) 5
4 (—) 3
53 (—) gff
— (—) / 03948475
— (—) 3
— (—) dksjdh

I put secent column in (column2)
And i need pattern in(I think) Regex to recognize first and last column for this cases…
Ill be grateful for some idea :))

BTW i got putter where i recognize (column2)that why i can cut out column1 and column3 but there is missing method for column2

Many thanks,
Regard,
@fudi5


#8

This is the input, but what is the expected output?


#10

Solution is here: Take out value form variable matchcollection

Many thanks for help,
Regards,
@fudi5