ShiftJIS::Regexp contains regular expressions in Shift-JIS.
SYNOPSIS
use ShiftJIS::Regexp qw(:all);
match($string, 'p{Hiragana}{2}p{Digit}{2}');
match($string, 'pH{2}pD{2}');
# these two are equivalent:
This module provides some functions to use regular expressions in Shift-JIS on the byte-oriented perl.
The legal Shift-JIS character in this module must match the following regular expression:
[x00-x7FxA1-xDF]|[x81-x9FxE0-xFC][x40-x7Ex80-xFC]
To avoid false matching in multibyte encoding, this module uses anchoring technique to ensure each matching position places at the character boundaries.
cf. perlfaq6, "How can I match strings with multibyte characters?"
Functions
re(PATTERN)
re(PATTERN, MODIFIER)
Returns a regular expression parsable by the byte-oriented perl.
PATTERN is specified as a string. MODIFIER is specified as a string. Modifiers in the following list are allowed.
i case-insensitive pattern (only for ascii alphabets)
I case-insensitive pattern (greek, cyrillic, fullwidth latin)
j hiragana-katakana-insensitive pattern (but halfwidth katakana
are not considered.)
s treat string as single line
m treat string as multiple lines
x ignore whitespace (i.e. [x20nrtf]) unless backslashed
or inside a character class; but comments are not recognized!
o once parsed (not compiled!) and the result is cached internally.
o modifier
while () {
print replace($_, '(perl)', '$1', 'igo');
}
is more efficient than
while () {
print replace($_, '(perl)', '$1', 'ig');
}
because in the latter case the pattern is parsed every time
whenever the function is called.
match(STRING, PATTERN)
match(STRING, PATTERN, MODIFIER)
An emulation of m// operator aware of Shift-JIS. But, to emulate @list = $string =~ m/PATTERN/g, the pattern should be parenthesized (capturing parentheses are not added automatically).
@list = match($string, 'pH', 'g'); # wrong; returns garbage!
@list = match($string,'(pH)','g'); # good
PATTERN is specified as a string. MODIFIER is specified as a string.
i,I,j,s,m,x,o please see re().
g match globally
z tell the function the pattern matches an empty string
(sorry, due to the poor auto-detection)
replace(STRING or SCALAR REF, PATTERN, REPLACEMENT)
replace(STRING or SCALAR REF, PATTERN, REPLACEMENT, MODIFIER)
An emulation of s/// operator but aware of Shift-JIS.
If a reference to a scalar is specified as the first argument, substitutes the referent scalar and returns the number of substitutions made. If a string (not a reference) is specified as the first argument, returns the substituted string and the specified string is unaffected.
MODIFIER is specified as a string.
i,I,j,s,m,x,o please see re().
g,z please see match().
jsplit(PATTERN or ARRAY REF of [PATTERN, MODIFIER], STRING)
jsplit(PATTERN or ARRAY REF of [PATTERN, MODIFIER], STRING, LIMIT)
An emulation of CORE::split but aware of Shift-JIS.
In scalar/void context, it does not split into the @_ array; in scalar context, only returns the number of fields found.
PATTERN is specified as a string. But ' ' as PATTERN has no special meaning; it splits the string on a single space similarly to CORE::split / /.
When you want to split the string on whitespace, pass an undefined value as PATTERN or use the splitspace() function.
jsplit(undef, " x81x40 This is x81x40 perl.");
splitspace(" x81x40 This is x81x40 perl.");
# ('This', 'is', 'perl.')
If you want to pass pattern with modifiers, specify an arrayref of [PATTERN, MODIFIER] as the first argument. You can also use "Embedded Modifiers").
MODIFIER is specified as a string.
i,I,j,s,m,x,o please see re().
splitspace(STRING)
splitspace(STRING, LIMIT)
This function emulates CORE::split(' ', STRING, LIMIT). It returns a list given by split STRING on whitespace including "x81x40" (IDEOGRAPHIC SPACE). Leading whitespace characters do not produce any field.
Note: splitspace(STRING, LIMIT) is equivalent to jsplit(undef, STRING, LIMIT).
splitchar(STRING)
splitchar(STRING, LIMIT)
This function emulates CORE::split(//, STRING, LIMIT). It returns a list given by split of STRING into characters.
Note: splitchar(STRING, LIMIT) is equivalent to jsplit('', STRING, LIMIT).
Requirements:
· Perl
Product's homepage