CyberArmy University | Open Source Institute | CyberArmy Intelligence & Security | CyberArmy Services & Projects

preg replace woes


[Reply] [View by Thread] [Help]
[Back To Programming]

Posted by Alpha Lt Cyben On 2008-07-28 14:37:19

Alpha LtAlpha Lt
Alpha Lt Cyben


Hi

Well I'm fairly new to regexp - and *gasp* have never used perl. I am, on the other hand, trying to write something in php that will get rid of newlines IF they're inside quotes. Here's the background:

What I've got to work with is a huge excel file, exported as tab-delimited text. Sadly, many of the cells contain the newline character. However, if a cell contains this newline character, its contents are surrounded in doublequotes. I want to replace all of these newline chars with " -- ". So, I need to replace every instance of:

([tab] OR [newline])"sometext[newline](sometext[newline])*"([tab] OR [newline])

with

([tab] OR [newline])"sometext -- sometext (or as many as there are)"([tab] OR [newline])

Does anyone know the pattern/replacement for how to do this? And better yet (or preferably in addition), does anyone know where I can get a good tutorial on this? Regexp tends to looks like line-noise to me =\

--------------------------------
Lt Cyben


There are no replies to this post yet.



Guest:
Subject:
Message:
Signature:
Optional Image Link:
http://

CyberArmy::Forum v0.6
Generated In 0.00476 seconds


About Us | Privacy Policy | Mission Statement | Help