in reply to Re: regex to add network line-endings if required.
in thread regex to add network line-endings if required.
" You use both "platform specific line-ending" and "network line-ending." Is the use of two different phrases accidental or purposeful?"
Very purposeful.
The sub will receive strings for transmission across the network. The caller may have terminated the string with "\n" (which will be the platform-sepecific line-ending dependant upon what the current platform is), or they may not have done so.
Before transmission, I need to:
It seems like a single regex that used look-behind assertions properly would be able to do this, thereby avoiding messy conditional logic. It also seems like this is an oft-called for requirement and a well tried solution is probably already known.
I've had a couple of attempts at constructing the regex, but in each case, it falls over in one of the above three cases. Either adding an extra, unnecessary line-ending or omitting to add one.
I hoped someone in the know would point me at the correct regex to use?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: regex to add network line-endings if required.
by mr_mischief (Monsignor) on Feb 15, 2005 at 18:28 UTC | |
by BrowserUk (Patriarch) on Feb 15, 2005 at 19:00 UTC | |
by mr_mischief (Monsignor) on Feb 15, 2005 at 20:27 UTC | |
|
Re^3: regex to add network line-endings if required.
by tphyahoo (Vicar) on Feb 15, 2005 at 17:30 UTC |