[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

rexexp question

ishamid

12/2/2006 10:06:00 PM

[total novice again ;-)]

Hi,

Ok, I've figured some of this pattern-matching out (yes, I'm really a
total novice at programming). Consider the following:

====================================
@data.gsub!(/<(text:span
text:style-name="T10")>(.*?)<\/text:span>/mois) do
'{' + '\bf ' + $2 + '}'
end
@data.gsub!(/<(text:span
text:style-name="Style2")>(.*?)<\/text:span>/mois) do
'{' + '\it ' + $2 + '}'
end
@data.gsub!(/<text:span.*?text:style-name=([\'\"])(.*?)\1>(.*?)<\/text:span>/)
do
tag, text = $2, $3
if inline[tag] then
(inline[tag][0]||'') + clean_display(text) +
(inline[tag][1]||'')
else
clean_display(text)
end
end
====================================

How can I condense this? I want something that says, eg.

If style-name equals "T10" or "Style2" or "Style3" then do \bf or \it
or \sl respectively. Otherwise, do clean_display (defined elsewhere).
The first line should look like this

==================
@data.gsub!(/<(text:span
text:style-name=("T10"|"Style2"|"Style3"))>(.*?)<\/text:span>/mois) do
==================

but how do I modify the

==================
'{' + '\bf ' + $2 + '}'
==================

line?

Best
Idris

6 Answers

Paul Lutus

12/3/2006 1:12:00 AM

0

ishamid wrote:

/ ...

> ==================
> '{' + '\bf ' + $2 + '}'
> ==================
>
> line?

It would be helpful if you could providea complete (short) example of the
data to be processed, plus a statement about the relationship between the
contents of the data and the desired outcomes. Without necessarily showing
what you have tried.

IOW show an example of the data, say what outcomes for what data content.

What you have posted are examples of your regexps and some of the things
that went wrong, but no full examples of data, so it's hard to see why it
went wrong.

There are quite a few regular posters here who are pretty good with regular
expressions. I am sure we can offer some useful hints if we can see the
data plus the desired outcomes.

--
Paul Lutus
http://www.ara...

dblack

12/3/2006 1:30:00 AM

0

ishamid

12/3/2006 3:13:00 AM

0

Hi Paul,

On Dec 2, 6:11 pm, Paul Lutus <nos...@nosite.zzz> wrote:
> ishamid wrote:/ ...
>
> > ==================
> > '{' + '\bf ' + $2 + '}'
> > ==================

<snip>

> There are quite a few regular posters here who are pretty good with regular
> expressions. I am sure we can offer some useful hints if we can see the
> data plus the desired outcomes.

Ok, I was trying to avoid typing too much :-) but I will post more
detail tomorrow morning. I am new to ruby, this list, and serious
programming so please bear with me as I get the hang of
appropriate/informative communication on this list.

Thank you, Paul!
Idris

kensi

3/8/2013 8:02:00 PM

0

On 08/03/2013 12:12 PM, Sir Gregory Hall, Esq? wrote:
> "Nadegda" <nad318b404@gmail.invalid> wrote in message
> news:khbkg2$j7e$9@dont-email.me...
>> On Thu, 07 Mar 2013 16:35:45 -0500, Sir Gregory Hall, Esq? wrote:
>>> "pandora" <pandora@peak.org> wrote in message
>>> news:3d-dnYJtNrHomqTMnZ2dnUVZ_sidnZ2d@scnresearch.com...
>>>> Tough!
>>>
>>> What a cold beeatch!
>>
>> I wonder why you express such opinions of her, but continue trying to
>> pursue her at the same time. Genuinely conflicted feelings? Or are you
>> just lying when you claim to hold the negative opinions?
>
>
> Unfortunately, she's married. That means she's not available at this
> time so I have to keep her interested in me until she becomes
> available.

Leaving aside the matter of whether you "have" to do anything ... what
has to break inside your brain for you to think your best way to "keep
her interested" is to frequently insult her in public?

> It is rumored that her husband is on his last leg so she might become
> available soonest!

That sort of cold-blooded attitude probably doesn't help much either.

--
"To explain the unknown by the known is a logical procedure; to explain
the known by the unknown is a form of theological lunacy." ~David Brooks
"A clue, a clue. My kingdom for a clue!!!!" ~Gweggles,
in an uncommon moment of self-awareness.

Sir Gregory Hall, Esq?

3/8/2013 8:16:00 PM

0

"kensi" <kkensington01@gmail.invalid> wrote in
message news:khdg38$k65$1@speranza.aioe.org...
> On 08/03/2013 12:12 PM, Sir Gregory Hall, Esq? wrote:
>> "Nadegda" <nad318b404@gmail.invalid> wrote in message
>> news:khbkg2$j7e$9@dont-email.me...
>>> On Thu, 07 Mar 2013 16:35:45 -0500, Sir Gregory Hall, Esq? wrote:
>>>> "pandora" <pandora@peak.org> wrote in message
>>>> news:3d-dnYJtNrHomqTMnZ2dnUVZ_sidnZ2d@scnresearch.com...
>>>>> Tough!
>>>>
>>>> What a cold beeatch!
>>>
>>> I wonder why you express such opinions of her, but continue trying to
>>> pursue her at the same time. Genuinely conflicted feelings? Or are you
>>> just lying when you claim to hold the negative opinions?
>>
>>
>> Unfortunately, she's married. That means she's not available at this time
>> so I have to keep her interested in me until she becomes available.
>
> Leaving aside the matter of whether you "have" to do anything ... what has
> to break inside your brain for you to think your best way to "keep her
> interested" is to frequently insult her in public?

Women crave attention - any kind of attention. They just don't feel
good about themselves unless they are being paid attention to.
Of course they would like positive reinforcement but even negative
reinforcement beats being ignored completely.

>> It is rumored that her husband is on his last leg so she might become
>> available soonest!
>
> That sort of cold-blooded attitude probably doesn't help much either.

Hey, nobody lives forever. Women can be very practical when it
comes to finding a new partner.

--
Sir Gregory



Dick Stuckey

3/9/2013 2:42:00 AM

0

In article <6da6i5.ehg.17.1@news.alt.net>, greghall@home.f?ke says...


>
> "kensi" <kkensington01@gmail.invalid> wrote in
> message news:khdg38$k65$1@speranza.aioe.org...
> > On 08/03/2013 12:12 PM, Sir Gregory Hall, Esq? wrote:
> >> "Nadegda" <nad318b404@gmail.invalid> wrote in message
> >> news:khbkg2$j7e$9@dont-email.me...
> >>> On Thu, 07 Mar 2013 16:35:45 -0500, Sir Gregory Hall, Esq? wrote:
> >>>> "pandora" <pandora@peak.org> wrote in message
> >>>> news:3d-dnYJtNrHomqTMnZ2dnUVZ_sidnZ2d@scnresearch.com...
> >>>>> Tough!
> >>>>
> >>>> What a cold beeatch!
> >>>
> >>> I wonder why you express such opinions of her, but continue trying to
> >>> pursue her at the same time. Genuinely conflicted feelings? Or are you
> >>> just lying when you claim to hold the negative opinions?
> >>
> >>
> >> Unfortunately, she's married. That means she's not available at this time
> >> so I have to keep her interested in me until she becomes available.
> >
> > Leaving aside the matter of whether you "have" to do anything ... what has
> > to break inside your brain for you to think your best way to "keep her
> > interested" is to frequently insult her in public?
>
> Women crave attention - any kind of attention.

So you're a woman?


> They just don't feel
> good about themselves unless they are being paid attention to.
> Of course they would like positive reinforcement but even negative
> reinforcement beats being ignored completely.
>
> >> It is rumored that her husband is on his last leg so she might become
> >> available soonest!
> >
> > That sort of cold-blooded attitude probably doesn't help much either.
>
> Hey, nobody lives forever. Women can be very practical when it
> comes to finding a new partner.



--
Dick Stuckey