![]() |
|
|
#1 |
|
Guest
Posts: n/a
|
regular expression 'or-ed' - doesnt work!
Hi,
I'm totally new to this forum, and relatively new to regexp. What I am looking for is an expression that in a pieace of TSQL code, will move the function header, and then all whitespaces in it. I came up with this one: \s||(^(.|\n)*((create\s*view)|(create\s*proc)|(cre ate\s*function)| (create\s*trigger))) So, its basically, 'all whitespaces, or anything that's at the beginning of the header (create [entity type]... that's TSQL) I think this works ok, though I haven't tested much. (Does it make sense?) now my question is, when I change the order: (^(.|\n)*((create\s*view)|(create\s*proc)|(create\ s*function)|(create \s*trigger)))||\s The \s doesn't work! It doesn't clear out whitespaces. Now why is that? If its this-or-that, why does the order matters? I have a feeling that fundamentally I misunderstood something.... Thanks! |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Re: regular expression 'or-ed' - doesnt work!
Jonathan Sion wrote:
> Hi, > I'm totally new to this forum, and relatively new to regexp. What I am > looking for is an expression that in a pieace of TSQL code, will move > the function header, and then all whitespaces in it. I came up with > this one: > > \s||(^(.|\n)*((create\s*view)|(create\s*proc)|(cre ate\s*function)| > (create\s*trigger))) > > So, its basically, 'all whitespaces, or anything that's at the > beginning of the header (create [entity type]... that's TSQL) > > I think this works ok, though I haven't tested much. (Does it make > sense?) now my question is, when I change the order: > (^(.|\n)*((create\s*view)|(create\s*proc)|(create\ s*function)|(create > \s*trigger)))||\s > > The \s doesn't work! It doesn't clear out whitespaces. Now why is > that? If its this-or-that, why does the order matters? I have a > feeling that fundamentally I misunderstood something.... > > Thanks! > Perhaps I'm misunderstanding what you want to do, but \s doesn't "clear out whitespaces". \s matches 1 whitespace character. Also, why do you have two bars there, ie. ||\s or \s|| ? (perhaps that's some regex syntax I'm unfamiliar with). Also, try explaining what it is you want to match, instead of just asking wether your current solution is right. You mention you want to "move" the function header. Move how/where? If you could give us short-but-complete code and example input and output, that would probably go a long way. -- Lasse Vågsæther Karlsen mailto:lasse@vkarlsen.no http://presentationmode.blogspot.com/ |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Re: regular expression 'or-ed' - doesnt work!
Jonathan Sion wrote:
> Hi, > I'm totally new to this forum, and relatively new to regexp. What I am > looking for is an expression that in a pieace of TSQL code, will move > the function header, and then all whitespaces in it. I came up with > this one: > > \s||(^(.|\n)*((create\s*view)|(create\s*proc)|(cre ate\s*function)| > (create\s*trigger))) > > So, its basically, 'all whitespaces, or anything that's at the > beginning of the header (create [entity type]... that's TSQL) > > I think this works ok, though I haven't tested much. (Does it make > sense?) now my question is, when I change the order: > (^(.|\n)*((create\s*view)|(create\s*proc)|(create\ s*function)|(create > \s*trigger)))||\s > > The \s doesn't work! It doesn't clear out whitespaces. Now why is > that? If its this-or-that, why does the order matters? I have a > feeling that fundamentally I misunderstood something.... > > Thanks! > Perhaps I'm misunderstanding what you want to do, but \s doesn't "clear out whitespaces". \s matches 1 whitespace character. Also, why do you have two bars there, ie. ||\s or \s|| ? (perhaps that's some regex syntax I'm unfamiliar with). Also, try explaining what it is you want to match, instead of just asking wether your current solution is right. You mention you want to "move" the function header. Move how/where? If you could give us short-but-complete code and example input and output, that would probably go a long way. -- Lasse Vågsæther Karlsen mailto:lasse@vkarlsen.no http://presentationmode.blogspot.com/ |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
| New To Site? | Need Help? |