public final class SedFactory extends Object implements Sed.Interface<SedCommand>
sed
command returning
a new command instance from every signature method.Modifier and Type | Field and Description |
---|---|
static SedFactory |
INSTANCE
The singleton instance of this factory.
|
Modifier and Type | Method and Description |
---|---|
SedCommand |
sed(SedOptions options,
String regexp)
Executes the sed command specified by the given options or executes
the print command p if no command option has been declared.
|
SedCommand |
sed(SedOptions options,
String string1,
String string2)
Executes the sed command specified by the given options or executes
the substitute command s if no command option has been declared.
|
SedCommand |
sed(SedOptions options,
String string1,
String string2,
int... occurrence)
Executes the sed command specified by the given options or executes
the substitute command s if no command option has been declared.
|
SedCommand |
sed(String... args)
Executes the sed script specified by the given arguments and writes
the result to the standard output.
|
SedCommand |
sed(String script)
Executes the given sed script, such as "s/original/replacement/g".
|
SedCommand |
sed(String regexp,
String replacement)
Substitutes the replacement string for instances of the regexp in
the matched line.
|
SedCommand |
sed(String regexp,
String replacement,
int... occurrence)
Substitutes the replacement string for instances of the regexp in
the matched line.
|
public static final SedFactory INSTANCE
public SedCommand sed(String... args)
Sed.Interface
Options can be specified by acronym (with a leading dash "-") or by long name (with two leading dashes "--"). Operands other than the default "--script" operand have to be prefixed with the operand name.
sed
in interface Sed.Interface<SedCommand>
args
- String arguments defining the options and operands for the command.
Options can be specified by acronym (with a leading dash "-") or by
long name (with two leading dashes "--"). Operands other than the
default "--script" operand have to be prefixed with the operand name
(e.g. "--occurrence" for subsequent occurrence indices).<R>
defined by the implementing class;
the command itself returns no value and writes its result to the
standard output; see class level parameter comments for more
detailspublic SedCommand sed(String script)
Sed.Interface
sed
in interface Sed.Interface<SedCommand>
script
- Sed script as one string, such as "s/original/replacement/g".<R>
defined by the implementing class;
the command itself returns no value and writes its result to the
standard output; see class level parameter comments for more
detailspublic SedCommand sed(String regexp, String replacement)
Sed.Interface
The characters "$0" appearing in the replacement are replaced by the line matching the regexp. The characters "$n", where n is a digit other than zero, are replaced by the text matched by the corresponding backreference expression (aka group). The special meaning of "$n" in this context can be suppressed by preceding it by a backslash.
A line can be split by substituting a newline ('\n') into it.
A substitution is considered to have been performed even if the replacement string is identical to the string that it replaces.
sed
in interface Sed.Interface<SedCommand>
regexp
- Regular expression matched against a line.replacement
- Replacement string for substitute command. The characters "$0"
appearing in the replacement are replaced by the line matching
the regexp. The characters "$n", where n is a digit other than zero,
are replaced by the text matched by the corresponding backreference
expression (aka group). The special meaning of "$n" in this context
can be suppressed by preceding it by a backslash.<R>
defined by the implementing class;
the command itself returns no value and writes its result to the
standard output; see class level parameter comments for more
detailspublic SedCommand sed(String regexp, String replacement, int... occurrence)
Sed.Interface
The characters "$0" appearing in the replacement are replaced by the line matching the regexp. The characters "$n", where n is a digit other than zero, are replaced by the text matched by the corresponding backreference expression (aka group). The special meaning of "$n" in this context can be suppressed by preceding it by a backslash.
A line can be split by substituting a newline ('\n') into it.
A substitution is considered to have been performed even if the replacement string is identical to the string that it replaces.
sed
in interface Sed.Interface<SedCommand>
regexp
- Regular expression matched against a line.replacement
- Replacement string for substitute command. The characters "$0"
appearing in the replacement are replaced by the line matching
the regexp. The characters "$n", where n is a digit other than zero,
are replaced by the text matched by the corresponding backreference
expression (aka group). The special meaning of "$n" in this context
can be suppressed by preceding it by a backslash.occurrence
- Substitute for the given occurrences only of the regexp found within
the matched string; the occurrence indices are one-based. If empty
or omitted, all occurrences are substituted.
(This operand only applies to the substitute command and is ignored by all other commands).
<R>
defined by the implementing class;
the command itself returns no value and writes its result to the
standard output; see class level parameter comments for more
detailspublic SedCommand sed(SedOptions options, String regexp)
Sed.Interface
sed
in interface Sed.Interface<SedCommand>
options
- Sed options and commandsregexp
- Regular expression matched against a line.<R>
defined by the implementing class;
the command itself returns no value and writes its result to the
standard output; see class level parameter comments for more
detailspublic SedCommand sed(SedOptions options, String string1, String string2)
Sed.Interface
sed
in interface Sed.Interface<SedCommand>
options
- Sed options and commandsstring1
- Regular expression matched against a line for all commands except
for command y where string1 contains the source characters for the
translation.string2
- Replacement string for substitute command s; appended, inserted or
changed text for a, i and c command; destination characters for
translate command y; ignored by all other commands.
If string2 is a replacement string for the substitute command: the characters "$0" appearing in the replacement are replaced by the line matching the regexp; the characters "$n", where n is a digit other than zero, are replaced by the text matched by the corresponding backreference expression (aka group). The special meaning of "$n" in this context can be suppressed by preceding it by a backslash.
(This operand only applies to the commands s, a, i, c and y and is ignored by all other commands).
<R>
defined by the implementing class;
the command itself returns no value and writes its result to the
standard output; see class level parameter comments for more
detailspublic SedCommand sed(SedOptions options, String string1, String string2, int... occurrence)
Sed.Interface
The string1 operand usually contains the regular expression matched against a line for all commands except for command y where string1 contains the source characters for the translation.
The string2 operand contains the replacement string for the substitute command s. It contains the appended, inserted or changed text for the commands a, i and c, respectively, and the destination characters for the translate command y. All other commands ignore the string2 operand.
sed
in interface Sed.Interface<SedCommand>
options
- Sed options and commandsstring1
- Regular expression matched against a line for all commands except
for command y where string1 contains the source characters for the
translation.string2
- Replacement string for substitute command s; appended, inserted or
changed text for a, i and c command; destination characters for
translate command y; ignored by all other commands.
If string2 is a replacement string for the substitute command: the characters "$0" appearing in the replacement are replaced by the line matching the regexp; the characters "$n", where n is a digit other than zero, are replaced by the text matched by the corresponding backreference expression (aka group). The special meaning of "$n" in this context can be suppressed by preceding it by a backslash.
(This operand only applies to the commands s, a, i, c and y and is ignored by all other commands).
occurrence
- Substitute for the given occurrences only of the regexp found within
the matched string; the occurrence indices are one-based. If empty
or omitted, all occurrences are substituted.
(This operand only applies to the substitute command and is ignored by all other commands).
<R>
defined by the implementing class;
the command itself returns no value and writes its result to the
standard output; see class level parameter comments for more
detailsCopyright © 2024. All rights reserved.