Using Python 2.7, want to use regular expression to find the Hello part of a given string. The rule is, Hello maybe in the pattern starts with {(1N), {(2N) (until 10N), or combination of them {(1N,2N,3N,4N), and ends with }.
Besides match the Hello part, I also want to know if 1N match, or 2N match or 10N match, or either 1N or 2N match.
Any solutions are appreciated.
Some content {(1N,2N,3N,4N) Hello } Some content
Some content {(1N) Python } Some content
Some content {(2N) Regex } Some content
In the first example, I want to know 1N,2N,3N,4N matches, and the matched string is Hello;
In the 2nd example, I want to know 1N matches, and matched string is Python;
In the 3rd example, I want to know 2N matches, and matched string is Regex;
regards, Lin
{(1N (.*?) }through{(10N (.*?) }, match 10 times for a given string, which sounds a bit stupid and I also need to remove some prefix unnecessary matches, so it is why I come here to ask. Do you have some more efficient solutions? :)\{\(.*?\) Hello \}part.Hellopart could be any string, I just useHelloas example, I will update the question. If you have any good ideas, it will be great.