Nick Fitzsimons wrote:
> On 17 Oct 2007, at 13:47, Chris Knowles wrote:
>
>> Nick Fitzsimons wrote:
>>> Word boundaries aren't right either; for exmple, they will match a
>>> hyphen, so matching on some-thing will match some-thing-else. As per the
>>> HTML spec, class names are space-separated, so you need to match on
>>> spaces and the beginning or end of the string.
>>>
>>
>> of course, class names are separated by whitespace so hopefully this is
>> it...
>>
>> var re = new RegExp('\\s' + className + '\\s');
>
> Nope, that won't match "thing" to "thing", only to " thing " - you need
> to check for the start or end of the string as well as a space :-)
>
> HTH,
>
> Nick.
sorry Nick, as stated in your previous post, whitespace and end of lines.
This should cover the 4 possiblities:
"thing"
" thing"
"thing "
" thing "
var re = new RegExp("(^|\\s)" + className + "(\\s|$)")
or better still, use this get elements by class function you mentioned
then process the elements:
http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
--
Chris Knowles
*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************