String::Gsub - regex on string object


String-Gsub documentation Contained in the String-Gsub distribution.

Index


Code Index:

NAME

Top

String::Gsub - regex on string object

VERSION

Top

Version 0.04

SYNOPSIS

Top

 use String::Gsub qw(gstr);

 print gstr("abcabc")->gsub(qr/b/,sub{uc$1}); # ==> "aBcaBc"
 print gstr("hw")->gsub(qr/h/,"Hello")->gsub(qr/w/,"World"); # ==> "HelloWorld"

EXPORT

Top

This module can export gstr. No functions are exported by default.

FUNCTIONS

Top

gstr($str)

Alias for String::Gsub->new($str);

METHODS

Top

$pkg->new($str)

Create new instance.

$this->gsub($regexp, $replacement)

process global substitute, and return new object.

$this->gsubx($regexp, $replacement)

like gsub, but replace self object and return itself.

$this->sub($regexp, $replacement)

process one substitute, and return new object.

$this->subx($regexp, $replacement)

like sub, but replace self object and return itself.

$this->stringy()

returns string value contained in.

AUTHOR

Top

YAMASHINA Hio, <hio at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-string-gsub at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=String-Gsub. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc String::Gsub

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/String-Gsub

* CPAN Ratings

http://cpanratings.perl.org/d/String-Gsub

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=String-Gsub

* Search CPAN

http://search.cpan.org/dist/String-Gsub

SEE ALSO

Top

String::Gsub, String::Gsub::Functions

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


String-Gsub documentation Contained in the String-Gsub distribution.

## ----------------------------------------------------------------------------
#  String::Gsub
# -----------------------------------------------------------------------------
# Mastering programmed by YAMASHINA Hio
#
# Copyright 2006 YAMASHINA Hio
# -----------------------------------------------------------------------------
# $Id$
# -----------------------------------------------------------------------------
package String::Gsub;
use warnings;
use strict;

use String::Gsub::Functions;
use base qw(Exporter);
use overload q|""| => \&stringy;
our @EXPORT_OK = qw(gstr);

our $VERSION = '0.04';


1;

# -----------------------------------------------------------------------------
# gstr($str).
#
sub gstr($)
{
	__PACKAGE__->new(shift);
}

# -----------------------------------------------------------------------------
# $pkg->new($str).
#
sub new
{
	my $pkg = shift;
	my $str = shift;
	bless {s=>$str}, $pkg;
}

# -----------------------------------------------------------------------------
# $gstr->gsubx($regex, $replacement);
#   $regex is qr// or "string".
#   $replacement is sub{} or "string".
#
sub gsubx
{
	my $this = shift;
	my $re = shift;
	my $sub = shift;
	
	&String::Gsub::Functions::gsubx($this->{s}, $re, $sub, @_);
	$this;
}

# -----------------------------------------------------------------------------
# $gstr->gsub($regex, $replacement);
#   $regex is qr// or "string".
#   $replacement is sub{} or "string".
#
sub gsub
{
	my $this = shift;
	my $re = shift;
	my $sub = shift;
	
	gstr(&String::Gsub::Functions::gsub($this->{s}, $re, $sub, @_));
}

# -----------------------------------------------------------------------------
# $gstr->subx($regex, $replacement);
#   $regex is qr// or "string".
#   $replacement is sub{} or "string".
#
sub subx
{
	my $this = shift;
	my $re = shift;
	my $sub = shift;
	
	&String::Gsub::Functions::subsx($this->{s}, $re, $sub, @_);
	$this;
}

# -----------------------------------------------------------------------------
# $gstr->sub($regex, $replacement);
#   $regex is qr// or "string".
#   $replacement is sub{} or "string".
#
sub sub
{
	my $this = shift;
	my $re = shift;
	my $sub = shift;
	
	gstr(&String::Gsub::Functions::subs($this->{s}, $re, $sub, @_));
}

# -----------------------------------------------------------------------------
# $gstr->stringy()
#   return string contained in.
#
sub stringy
{
	my $this = shift;
	$this->{s};
}

__END__

# -----------------------------------------------------------------------------
# End of File.
# -----------------------------------------------------------------------------