_kane81 Posted November 10, 2009 Share Posted November 10, 2009 I'm not good at regular expressions so I was hoping someone here can point me to what is wrong with my expression.... I'm trying to remove the code in between "method ChangeCurrentUserId" and "end-method". I am using the following expression (^method .*)([^*]*)(^end-method;) replace expression $1$3 The expression fails when it encounters '/* xxx */' - if I change the '*' to say a + the expression works. .... anyone with ideas? Thanks /** * ChangeCurrentUserId * * * @param &newUserId to switch to. * @return if the switch was successful. */ method ChangeCurrentUserId /+ &newUserId as String +/ /+ Returns Boolean +/ If %UserId = &newUserId Then Return True; End-If; /* xxx */ If &count <> 2 Then Return False; Else .... Return ((%UserId = &newUserId) And (&switchOk)); End-If; end-method; Link to comment Share on other sites More sharing options...
0 _kane81 Posted November 10, 2009 Author Share Posted November 10, 2009 '^' worked out this is negate however if I take it out it doesn't work accross multiple lines... Any ideas why? Link to comment Share on other sites More sharing options...
0 _kane81 Posted November 10, 2009 Author Share Posted November 10, 2009 '^' worked out this is negate however if I take it out it doesn't work accross multiple lines... Any ideas why? Link to comment Share on other sites More sharing options...
0 nvme Posted November 10, 2009 Share Posted November 10, 2009 take the sample input above and show me what you expect the sample output to be. as a side note '^' can mean different things. if it's inside of a character class like so: "[^*]" then it means any character that is not a star. if it's not in a character class but at the beginning of a pattern like so: "^house" then it means the pattern has to start with the word house. so "house party" and "house color" match, but "my house" does not match. Link to comment Share on other sites More sharing options...
0 _kane81 Posted November 10, 2009 Author Share Posted November 10, 2009 Got the solution! (^method .*)((.|[\r\n])*?)(^end-method;) BTW it is really really complex, I worked it out from this website - it has 6 tries at getting this! http://ostermiller.org/findcomment.html Link to comment Share on other sites More sharing options...
Question
_kane81
I'm not good at regular expressions so I was hoping someone here can point me to what is wrong with my expression....
I'm trying to remove the code in between "method ChangeCurrentUserId" and "end-method". I am using the following expression
replace expression
The expression fails when it encounters '/* xxx */' - if I change the '*' to say a + the expression works. .... anyone with ideas?
Thanks
Link to comment
Share on other sites
4 answers to this question
Recommended Posts