As far as I know, the regular expression (.*) does match any number of any characters (any string) except newline. Does somebody know if it also excludes other special characters like \t and \r..? MarcoLuk - Thu Aug 24 11:39:34 EDT 2017 |
Re: Regular expression "regexp2("(.*?)")" excludes only \n? The DXL Refernece Manual says: . any single character except new line I think this is clear and works as described. But what will you express with the "?" after ".*"? The meaning is optional or zero or one time. This is not described in the Manual but works as in other regexp implementations. |
Re: Regular expression "regexp2("(.*?)")" excludes only \n? thsturm - Fri Aug 25 03:55:12 EDT 2017 The DXL Refernece Manual says: . any single character except new line I think this is clear and works as described. But what will you express with the "?" after ".*"? The meaning is optional or zero or one time. This is not described in the Manual but works as in other regexp implementations. Ok, thanks! In my help documentation of DOORS Client 9.3.0.4 is only being mentioned for .*: matches any number of any characters (any string). The question mark shall force the regex to search greedy. |
Re: Regular expression "regexp2("(.*?)")" excludes only \n? The "*" means repeat the expression bevor zero or more times. The "?" means repeat the expession bevore zero or one time (not documentet in the Manual). The "." means any character but newline. So
|
Re: Regular expression "regexp2("(.*?)")" excludes only \n? thsturm - Fri Aug 25 04:32:51 EDT 2017 The "*" means repeat the expression bevor zero or more times. The "?" means repeat the expession bevore zero or one time (not documentet in the Manual). The "." means any character but newline. So
Hey, Marco, you're right - the greediness modifier actually works in DOORS (also not documented). That's great!
string s = "aaa"
Regexp re = regexp2 "(aa*)"
if (re s) {
print s[match 1]
}
--> aaa (greedy)
string s = "aaa"
Regexp re = regexp2 "(aa*?)"
if (re s) {
print s[match 1]
}
--> a (not greedy) |
Re: Regular expression "regexp2("(.*?)")" excludes only \n? Hello Mike,
thank you for your observation: I had never thought of such a regexp possibility in DOORS.
Does anybody know, which regexp library is used in DOORS, since the documentation is very poor? |
Re: Regular expression "regexp2("(.*?)")" excludes only \n? Mike.Scharnow - Fri Aug 25 14:44:37 EDT 2017 Hey, Marco, you're right - the greediness modifier actually works in DOORS (also not documented). That's great!
string s = "aaa"
Regexp re = regexp2 "(aa*)"
if (re s) {
print s[match 1]
}
--> aaa (greedy)
string s = "aaa"
Regexp re = regexp2 "(aa*?)"
if (re s) {
print s[match 1]
}
--> a (not greedy) Hey Mike,
thank you for your demonstration. Yes, I use the question mark for a greedy search. I use this in python as well, where it is also documented. So I thought, it should work in DXL as well.
Sincerely Marco
|
Re: Regular expression "regexp2("(.*?)")" excludes only \n? thsturm - Mon Aug 28 03:17:57 EDT 2017 Hello Mike,
thank you for your observation: I had never thought of such a regexp possibility in DOORS.
Does anybody know, which regexp library is used in DOORS, since the documentation is very poor? @thsturm 8edf9132-c1a3-42b7-97b7-6a563ab61072: I don't know, but I think it's a selfmade library since it does not provide verything one would expect from a regexp lib, like whitespaces in character classes [\s], quantifiers {n,m}, backreferences \1 or non-capturing groups (?:)
@MarcoLuk 0089860a-aa27-49f8-83eb-07584a2d2c92: just to be precise |
Re: Regular expression "regexp2("(.*?)")" excludes only \n? Mike.Scharnow - Mon Aug 28 04:32:12 EDT 2017 @thsturm 8edf9132-c1a3-42b7-97b7-6a563ab61072: I don't know, but I think it's a selfmade library since it does not provide verything one would expect from a regexp lib, like whitespaces in character classes [\s], quantifiers {n,m}, backreferences \1 or non-capturing groups (?:)
@MarcoLuk 0089860a-aa27-49f8-83eb-07584a2d2c92: just to be precise @Mike.Scharnow: Ok, thanks, I was wondering your result at using "?" is "only" "a" and not "aaa". So I must think about if using non-greedy in my case (.*..) is correct...
Thank you very much again! |