Also is it possible to combine this with removing periods from within the string? The sentence may have spaces which I'd like to keep.
views:
75answers:
2
A:
You can find:
^[\r\f]+|[\r\f]+$
and replace it with
''
For the periods you can find
\.
and replace it with
''
Some languages provide you with function what take a a group of regex and replacements and do the replacement in one call to the function. Like the PHP's preg_replace.
codaddict
2010-03-31 05:27:19
Is there any reason you're matching `\f` (form feed) instead of `\n` (line feed)?
Max Shawabkeh
2010-03-31 06:07:23
+2
A:
Search for
^[\r\n]+|\.|[\r\n]+$
and replace with nothing.
The specific syntax will depend on the language you're using, e. g. in C#:
resultString = Regex.Replace(subjectString, @"^[\r\n]+|\.|[\r\n]+$", "");
in PHP:
$result = preg_replace('/^[\r\n]+|\.|[\r\n]+$/', '', $subject);
in JavaScript:
result = subject.replace(/^[\r\n]+|\.|[\r\n]+$/g, "");
etc...
Tim Pietzcker
2010-03-31 06:10:07