List Info

Thread: matching special characters in ruby reg ex




matching special characters in ruby reg ex
country flaguser name
United States
2007-08-18 14:48:34
Hi,
I'm trying to write a regex to strip wiki-like formating in
ruby.

in this section of wiki text, i want to retain just the
first
paragraph(starting with Microsoft Corporation) of this
article.
--------------
{{Infobox_Company
| company_name = Microsoft Corporation
| company_logo = [[Image:Microsoft logo.svg|220px|]]
| company_type = [[Public company|Public]]
({{nasdaq2|MSFT}})
...
}}

'''Microsoft Corporation''' ({{nasdaq|MSFT}}) is an [[United
States|
American]] [[multinational corporation|multinational]]
[[computer]]
technology [[corporation]] with 76,000 employees in 102
countries and
global annual [[revenue]] of [[United States dollar|US
$]]...
Originally founded to develop and sell [[BASIC programming
language|
BASIC]] [[interpreter ....
--------------

I'm thinking of remove anything inside {{ }}  characters. So
something
like /{{[ALL_CHARACTERS}}/
What can I define for ALL_CHARACTERS to match anything? I've
tried
[:print:] and wsd but they don't match the odd chars like
=,'.

Thanks,
Tommy


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


Re: matching special characters in ruby reg ex
country flaguser name
United States
2007-08-20 05:21:05

> I'm thinking of remove anything inside {{ }} 
characters. So something
> like /{{[ALL_CHARACTERS}}/
> What can I define for ALL_CHARACTERS to match anything?
I've tried
> [:print:] and wsd but they don't match the odd chars
like =,'.
>

Hi Tommy,

You essentially need anything within {{}}, so please try
negating
these two characters in a character class this way [^{}]

Thanks
Syd



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )