MYSQL Regex

View: New views
5 Messages — Rating Filter:   Alert me  

MYSQL Regex

by Deco Rior (Tennissource) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Does anyone have the regex for a mysql replace statement to remove  
parentheses and anything inside from a field?

e.g. test(abcd) => test

Deco

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/



Re: MYSQL Regex

by Steve Piercy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Do the reverse:

find:
(.*)\(.*

replace:
\1

=> test

Not sure of where you want to put the regexp, so I'll leave that
up to you.

--steve


On 10/30/09 at 9:47 AM, decorior@... (Deco Rior
(Tennissource)) pronounced:

>Does anyone have the regex for a mysql replace statement to
>remove parentheses and anything inside from a field?
>
>e.g. test(abcd) => test
>
>Deco
>
>--
>This list is a free service of LassoSoft: http://www.LassoSoft.com/
>Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>Manage your subscription: http://www.ListSearch.com/Lasso/
>
>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<web@...>                  <http://www.StevePiercy.com/>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/



Re: MYSQL Regex

by Deco Rior (Tennissource) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, Steve:

Thanks,

but I was looking to do it in the mysql query. I don't think mysql  
supports the replace?

Deco
On Oct 30, 2009, at 3:43 PM, Steve Piercy - Web Site Builder wrote:

> Do the reverse:
>
> find:
> (.*)\(.*
>
> replace:
> \1
>
> => test
>
> Not sure of where you want to put the regexp, so I'll leave that up  
> to you.
>
> --steve
>
>
> On 10/30/09 at 9:47 AM, decorior@... (Deco Rior  
> (Tennissource)) pronounced:
>
>> Does anyone have the regex for a mysql replace statement to remove  
>> parentheses and anything inside from a field?
>>
>> e.g. test(abcd) => test
>>
>> Deco
>>
>> --
>> This list is a free service of LassoSoft: http://www.LassoSoft.com/
>> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>> Manage your subscription: http://www.ListSearch.com/Lasso/
>>
>>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy               Web Site Builder               Soquel, CA
> <web@...>                  <http://www.StevePiercy.com/>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/



Re: MYSQL Regex

by Steve Piercy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yeah, I don't think so.  I think MySQL supports the matching
only, and returns 1 or 0 if a pattern matches a string.

http://dev.mysql.com/doc/refman/5.1/en/regexp.html

--steve


On 10/30/09 at 3:55 PM, decorior@... (Deco Rior
(Tennissource)) pronounced:

>Hi, Steve:
>
>Thanks,
>
>but I was looking to do it in the mysql query. I don't think
>mysql supports the replace?
>
>Deco
>On Oct 30, 2009, at 3:43 PM, Steve Piercy - Web Site Builder wrote:
>
>>Do the reverse:
>>
>>find:
>>(.*)\(.*
>>
>>replace:
>>\1
>>
>>=> test
>>
>>Not sure of where you want to put the regexp, so I'll leave
>>that up to you.
>>
>>--steve
>>
>>
>>On 10/30/09 at 9:47 AM, decorior@... (Deco Rior
>>(Tennissource)) pronounced:
>>
>>>Does anyone have the regex for a mysql replace statement to
>>>remove parentheses and anything inside from a field?
>>>
>>>e.g. test(abcd) => test
>>>
>>>Deco
>>>
>>>--
>>>This list is a free service of LassoSoft: http://www.LassoSoft.com/
>>>Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>>>Manage your subscription: http://www.ListSearch.com/Lasso/
>>>
>>>
>>
>>-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>Steve Piercy               Web Site Builder               Soquel, CA
>><web@...>                  <http://www.StevePiercy.com/>
>>
>>
>>--
>>This list is a free service of LassoSoft: http://www.LassoSoft.com/
>>Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>>Manage your subscription: http://www.ListSearch.com/Lasso/
>>
>>
>
>
>--
>This list is a free service of LassoSoft: http://www.LassoSoft.com/
>Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>Manage your subscription: http://www.ListSearch.com/Lasso/
>
>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<web@...>                  <http://www.StevePiercy.com/>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/



Re: MYSQL Regex

by James Harvard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

At 15:55 -0600 30/10/09, Deco Rior (Tennissource) wrote:
>I don't think mysql supports the replace?

No, but there is a third party solution that will allow MySQL to do Perl-compatible Regular Expressions, including replace.
http://www.mysqludf.org/lib_mysqludf_preg/

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/