Reg Ex Help for a Lazy VB Programmer

Discussion in 'Perl' started by adams114@comcast.net, Apr 19, 2004.

Guest

Ok,

I'm trying to count the number of characters in a string. Once the
count of character's reaches x I want to replace the rest of the
string with an web site link. So here's what I've come up with so
far, but I cannot figure out how to do the replace. Can you help me? I
cannot even get what I have to compile.

"*
while ($text =~ .\g){ # this is the error, . matching
# any character, g for greed
*"

s/.// if you want to substitute any one charecter by nothing.
* and ? are the greedy operators, and *? and ?? for non-greedy.
you should realy check perl's regular expressions.
Yaroslav has solved your problem in a better way than this on you
code:
"*
> while ($text =~ .\g){ # this is the error, . matching
> # any character, g for greed
> $count++;
> if ($count == $maxLength){
> $newText = $newText . $url;
> }
*"

[TOFU rearranged]
>
>
> wrote in message
> news:<>...
> > Ok,
> >
> > I'm trying to count the number of characters in a string. Once the
> > count of character's reaches x I want to replace the rest of the
> > string with an web site link. So here's what I've come up with so
> > far, but I cannot figure out how to do the replace. Can you help me? I
> > cannot even get what I have to compile.
> >
> >

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!