Jul-30-2018, 02:29 PM
Hi,
I have following text stored as a string:
Why does it not work as expected - to match any character except of ending curly bracket??
I have following text stored as a string:
Output:final class myClass1 {
const APPLICATION1 = 1;
const APPLICATION2 = 2;
}
final class myClass2 {
const APPLICATION3 = 3;
const APPLICATION4 = 4;
}
final class myClass3 {
const APPLICATION5 = 5;
const APPLICATION6 = 6;
}
I am trying to search the middle block (myClass2), but this pattern does not work:block = re.search(r'final\sclass\smyClass2\s{([ˆ}]+)}', text, re.DOTALL)while the next one matches everything up until the very last curly bracket:
block = re.search(r'final\sclass\smyClass2\s{(.+)}', text, re.DOTALL)Apparently the problem is with the [ˆ}]+ section of the pattern.
Why does it not work as expected - to match any character except of ending curly bracket??