1. Shlomi Fish
  2. perl-XML-LibXML

Commits

ph...@9ae0c189-cd1f-4510-a509-f4891f5cf20d  committed a890c8d

Modified Files:
LibXML.pm
+ deleteDataString()
better than the original deleteData() :)

  • Participants
  • Parent commits 3a3e157
  • Branches default

Comments (0)

Files changed (1)

File LibXML.pm

View file
     $pi->_setData( $string ) unless  $string =~ /\?>/;
 }
 
+sub XML::LibXML::Text::deleteDataString {
+    my $node = shift;
+    my $string = shift;
+    my $all    = shift;
+    my $data = $node->getData();
+    $string =~ s/([\\\*\+\^\{\}\&\?\[\]\(\)\$\%\@])/\$1/g;
+    if ( $all ) {
+        $data =~ s/$string//g;
+    }
+    else {
+        $data =~ s/$string//;
+    }
+    $node->setData( $data );
+}
 sub XML::LibXML::Text::replaceDataString {
-    my ( $node, $left, $right ) = @_;
+    my ( $node, $left, $right,$all ) = @_;
 
     #ashure we exchange the strings and not expressions!
     $left  =~ s/([\\\*\+\^\{\}\&\?\[\]\(\)\$\%\@])/\$1/g;
     $right =~ s/([\\\*\+\^\{\}\&\?\[\]\(\)\$\%\@])/\$1/g;
     my $datastr = $node->getData();
-    $datastr =~ s/$left/$right/;
+    if ( $all ) {
+        $datastr =~ s/$left/$right/g;
+    }
+    else{
+        $datastr =~ s/$left/$right/;
+    }
     $node->setData( $datastr );
 }