Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Answer: How do I write a regex which allows meta-quoting?

by WHolcomb (Initiate)
on Apr 13, 2000 at 19:39 UTC ( #7472=categorized answer: print w/replies, xml ) Need Help??

Q&A > regular expressions > How do I write a regex which allows meta-quoting? - Answer contributed by WHolcomb

Quite nearly there. All that is left is that things in brackets like array subscripts are made into links to other nodes. That ought to be fixable by replacing them with the html codes, which I don't know off the top of my head. Ahh, they are [ -> [ and ] -> ]

To the monks who maintain this monestary I might suggest that they have the node linking ignore []'s inside <pre>'s.
s/(^[(?:([^\\|\A)\\(\\{2})*\#)]*)(.*)/$1/

(?<!)

$c = "\#";
$m = "\\";

while(<IN>) {
  chomp;
  split /\Q$c\E/;
  $_ = $_[0];
  next if(/\A\s*\Z/);
  $string = $_;
  for($i = 1; $i <= $#_; $i++) {
   $_ = $_[$i - 1];
   m/(.)((\Q$m\E){2})*\Z/;
   if("$1" eq "$m") {
     $string .= "$c" . $_[$i];
   } else {
     last;
   }
  }
}

  • Comment on Answer: How do I write a regex which allows meta-quoting?
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[Corion]: Lady_Aleena: Mostly, it's just housekeeping, but it inspires me about things I could do with it, so that's good ;)
[Lady_Aleena]: By the way, I stopped by to let someone know I'm still alive, though I haven't found anything to write in perl for a while now.
[Lady_Aleena]: I need inspiration.
[Discipulus]: hello there: Lady_Aleena for inspiration random browse my homenode.. ;=)
[Lady_Aleena]: Discipulus, Hello there. How are you?

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2017-09-24 18:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (274 votes). Check out past polls.

    Notices?