quick regex question

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

quick regex question

French, Shelane
I've been doing this:
String_ReplaceRegExp(#name, -find='\\W', -replace='')

To remove non-alphanumeric characters from a string. If I want to allow a
hyphen, is there a "NOT" expression or a better way to write that replace?

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: quick regex question

Trevor Borgmeier

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: quick regex question

Trevor Borgmeier
In reply to this post by French, Shelane
try this:

String_ReplaceRegExp(#name, -find='^[a-zA-Z0-9]', -replace='');


sorry for the blank -- my accidental html emails are always reduced to
blank messages on this list.


on 6/12/14, 10:51 AM French, Shelane wrote:

> I've been doing this:
> String_ReplaceRegExp(#name, -find='\\W', -replace='')
>
> To remove non-alphanumeric characters from a string. If I want to allow a
> hyphen, is there a "NOT" expression or a better way to write that replace?
>
> #############################################################
> This message is sent to you because you are subscribed to
>    the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: quick regex question

James Harvard
I think you want that ^ inside the square brackets. And to add a hyphen in there.

[^A-Za-z0-9-]

On 12 Jun 2014, at 16:59, Trevor Borgmeier wrote:

> try this:
>
> String_ReplaceRegExp(#name, -find='^[a-zA-Z0-9]', -replace='');
>
>
> sorry for the blank -- my accidental html emails are always reduced to blank messages on this list.
>
>
> on 6/12/14, 10:51 AM French, Shelane wrote:
>> I've been doing this:
>> String_ReplaceRegExp(#name, -find='\\W', -replace='')
>>
>> To remove non-alphanumeric characters from a string. If I want to allow a
>> hyphen, is there a "NOT" expression or a better way to write that replace?
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>>   the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>>
>
> #############################################################
> This message is sent to you because you are subscribed to
> the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: quick regex question

French, Shelane
Yep. Thanks. That worked.

On 6/12/14, 10:11 AM, "James Harvard"
<[hidden email]> wrote:

I think you want that ^ inside the square brackets. And to add a hyphen in
there.

[^A-Za-z0-9-]

On 12 Jun 2014, at 16:59, Trevor Borgmeier wrote:

> try this:
>
> String_ReplaceRegExp(#name, -find='^[a-zA-Z0-9]', -replace='');
>
>
> sorry for the blank -- my accidental html emails are always reduced to
>blank messages on this list.
>
>
> on 6/12/14, 10:51 AM French, Shelane wrote:
>> I've been doing this:
>> String_ReplaceRegExp(#name, -find='\\W', -replace='')
>>
>> To remove non-alphanumeric characters from a string. If I want to allow
>>a
>> hyphen, is there a "NOT" expression or a better way to write that
>>replace?
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>>   the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>>
>
> #############################################################
> This message is sent to you because you are subscribed to
> the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: quick regex question

James Harvard
You may need to add an underscore too. \w matches underscore, I believe, so my guess would be that \W doesn't match it.
JH

On 12 Jun 2014, at 18:16, French, Shelane wrote:

> Yep. Thanks. That worked.
>
> On 6/12/14, 10:11 AM, "James Harvard"
> <[hidden email]> wrote:
>
> I think you want that ^ inside the square brackets. And to add a hyphen in
> there.
>
> [^A-Za-z0-9-]
>
> On 12 Jun 2014, at 16:59, Trevor Borgmeier wrote:
>
>> try this:
>>
>> String_ReplaceRegExp(#name, -find='^[a-zA-Z0-9]', -replace='');
>>
>>
>> sorry for the blank -- my accidental html emails are always reduced to
>> blank messages on this list.
>>
>>
>> on 6/12/14, 10:51 AM French, Shelane wrote:
>>> I've been doing this:
>>> String_ReplaceRegExp(#name, -find='\\W', -replace='')
>>>
>>> To remove non-alphanumeric characters from a string. If I want to allow
>>> a
>>> hyphen, is there a "NOT" expression or a better way to write that
>>> replace?
>>>
>>> #############################################################
>>> This message is sent to you because you are subscribed to
>>>  the mailing list Lasso [hidden email]
>>> Official list archives available at http://www.lassotalk.com
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>>
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: quick regex question

stevepiercy
[^A-Za-z0-9_-] will do that.

The - must be the last character in a character class, else it
gets interpreted as a range on either side of it.

--steve


On 6/12/14 at 10:32 PM, [hidden email]
(James Harvard) pronounced:

>You may need to add an underscore too. \w matches underscore, I
>believe, so my guess would be that \W doesn't match it.
>JH
>
>On 12 Jun 2014, at 18:16, French, Shelane wrote:
>
>>Yep. Thanks. That worked.
>>
>>On 6/12/14, 10:11 AM, "James Harvard"
>><[hidden email]> wrote:
>>
>>I think you want that ^ inside the square brackets. And to add a hyphen in
>>there.
>>
>>[^A-Za-z0-9-]
>>
>>On 12 Jun 2014, at 16:59, Trevor Borgmeier wrote:
>>
>>> try this:
>>>   String_ReplaceRegExp(#name, -find='^[a-zA-Z0-9]', -replace='');
>>>    sorry for the blank -- my accidental html emails are
>>>always reduced to
>>> blank messages on this list.
>>>    on 6/12/14, 10:51 AM French, Shelane wrote:
>>>> I've been doing this:
>>>> String_ReplaceRegExp(#name, -find='\\W', -replace='')
>>>>   To remove non-alphanumeric characters from a string. If I
>>>>want to allow
>>>> a
>>>> hyphen, is there a "NOT" expression or a better way to write that
>>>> replace?
>>>>   #############################################################
>>>> This message is sent to you because you are subscribed to
>>>>  the mailing list Lasso [hidden email]
>>>> Official list archives available at http://www.lassotalk.com
>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>> Send administrative queries to  <[hidden email]>
>>>>
>>>   #############################################################
>>> This message is sent to you because you are subscribed to
>>> the mailing list Lasso [hidden email]
>>> Official list archives available at http://www.lassotalk.com
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>
>>#############################################################
>>This message is sent to you because you are subscribed to
>>the mailing list Lasso [hidden email]
>>Official list archives available at http://www.lassotalk.com
>>To unsubscribe, E-mail to: <[hidden email]>
>>Send administrative queries to  <[hidden email]>
>>
>>#############################################################
>>This message is sent to you because you are subscribed to
>>the mailing list Lasso [hidden email]
>>Official list archives available at http://www.lassotalk.com
>>To unsubscribe, E-mail to: <[hidden email]>
>>Send administrative queries to  <[hidden email]>
>
>#############################################################
>This message is sent to you because you are subscribed to
>the mailing list Lasso [hidden email]
>Official list archives available at http://www.lassotalk.com
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy              Website Builder              Soquel, CA
<[hidden email]>               <http://www.StevePiercy.com/>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: quick regex question

Bil Corry-3
Or you can escape the hyphen:

[^A-Z\\-a-z0-9_]


- Bil


On Thu, Jun 12, 2014 at 11:55 PM, Steve Piercy - Web Site Builder <
[hidden email]> wrote:

> [^A-Za-z0-9_-] will do that.
>
> The - must be the last character in a character class, else it gets
> interpreted as a range on either side of it.
>
> --steve
>
>
> On 6/12/14 at 10:32 PM, [hidden email] (James
> Harvard) pronounced:
>
>
>  You may need to add an underscore too. \w matches underscore, I believe,
>> so my guess would be that \W doesn't match it.
>> JH
>>
>> On 12 Jun 2014, at 18:16, French, Shelane wrote:
>>
>>  Yep. Thanks. That worked.
>>>
>>> On 6/12/14, 10:11 AM, "James Harvard"
>>> <[hidden email]> wrote:
>>>
>>> I think you want that ^ inside the square brackets. And to add a hyphen
>>> in
>>> there.
>>>
>>> [^A-Za-z0-9-]
>>>
>>> On 12 Jun 2014, at 16:59, Trevor Borgmeier wrote:
>>>
>>>  try this:
>>>>   String_ReplaceRegExp(#name, -find='^[a-zA-Z0-9]', -replace='');
>>>>    sorry for the blank -- my accidental html emails are always reduced
>>>> to
>>>> blank messages on this list.
>>>>    on 6/12/14, 10:51 AM French, Shelane wrote:
>>>>
>>>>> I've been doing this:
>>>>> String_ReplaceRegExp(#name, -find='\\W', -replace='')
>>>>>   To remove non-alphanumeric characters from a string. If I want to
>>>>> allow
>>>>> a
>>>>> hyphen, is there a "NOT" expression or a better way to write that
>>>>> replace?
>>>>>   #############################################################
>>>>> This message is sent to you because you are subscribed to
>>>>>  the mailing list Lasso [hidden email]
>>>>> Official list archives available at http://www.lassotalk.com
>>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>>> Send administrative queries to  <[hidden email]>
>>>>>
>>>>>    #############################################################
>>>> This message is sent to you because you are subscribed to
>>>> the mailing list Lasso [hidden email]
>>>> Official list archives available at http://www.lassotalk.com
>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>> Send administrative queries to  <[hidden email]>
>>>>
>>>
>>> #############################################################
>>> This message is sent to you because you are subscribed to
>>> the mailing list Lasso [hidden email]
>>> Official list archives available at http://www.lassotalk.com
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>>
>>> #############################################################
>>> This message is sent to you because you are subscribed to
>>> the mailing list Lasso [hidden email]
>>> Official list archives available at http://www.lassotalk.com
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>>
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy              Website Builder              Soquel, CA
> <[hidden email]>               <http://www.StevePiercy.com/>
>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>