473,800 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple Regex question (~[^newline characters])

<?
// Test example:
echo '<pre>';
$aInput = '
abtgh kdghg 9867 jkuhkh
^ {
ooijj 438764 - 56_ 67
';
$aInput = ereg_replace('[^\n\r]', ',' , $aInput);
echo $aInput;
echo '</pre>';

Why doesn't this keep the newlines?
Instead it converts everything into ','.
?>

best regards
Thomas
Jul 16 '05 #1
2 4371
> $aInput = ereg_replace('[^\n\r]', ',' , $aInput);

$aInput = preg_replace('/[^\r\n]/', ',', $aInput);

best regards
Thomas
Jul 16 '05 #2
In article <3f************ ***********@dre ad11.news.tele. dk>,
"dk_sz" <dk***@hotmail. com> wrote:
$aInput = ereg_replace('[^\n\r]', ',' , $aInput);
echo $aInput;
echo '</pre>';

Why doesn't this keep the newlines?
Instead it converts everything into ','.


Put the pattern inside double-quotes instead of single quotes.

--
CC
Jul 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2709
by: lawrence | last post by:
When users enter urls or other long strings it can destroy the formatting of a page. A long url, posted in a comment, can cause page distortions that make the page unreadable, till the website owner logs in and deletes the comment. To protect against that, I'd like to break up long strings in the comments (anything submitted by anonymous sources). One thing I'd like to add to the following function is the ability to break up long...
0
1172
by: Andy | last post by:
Hi All I have a urgent problem with the regex object. I am currently reading in source code files (complete file including newline characters) as plain text into a string. i am then using a regex object to remove c-style multiline comments of the form /* ... */. My regular expression is /\*.*?\*/ and i have also turned on the regex singleline option that allows the dot character to match newline characters. the Regex is not matching the RE....
7
5731
by: alphatan | last post by:
Is there relative source or document for this purpose? I've searched the index of "Mastering Regular Expression", but cannot get the useful information for C. Thanks in advanced. -- Learning is to improve, but not to prove.
5
3023
by: John Baro | last post by:
I have a richtextbox which I want the "literal" rtf of. richtextbox.rtf returns {\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\uc1 }\r\n\0 when i put this into a string I get "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\uc1 }\r\n\0" I want this to be @"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\uc1 }\r\n\0" to treat the escape characters as literals
6
8886
by: Chris Anderson | last post by:
Anyone know of a fix (ideally) or an easy workaround to the problem of escape characters not working in regex replacement text? They just come out as literal text For example, you'd think that thi Regex.Replace("<stuff>text</stuff>", "<stuff>", "<stuff>\n" would give yo <stuff text</stuff
2
6061
by: Craig Buchanan | last post by:
I have a HTML fragment that looks like this: <tr> <td valign="top" nowrap><span class="textBold">Property ID: </span></td> <td valign="top" nowrap colspan="4" bgcolor="#F0F0F0"><b>&nbsp;01-068-24-64-1024</b></td> </tr> I am trying to extract the '' part of it.
2
1497
by: Phillip Vong | last post by:
I'm using VS2005 programming in VB.Net. I have a simple aspx page. In the Insert mode, I have a textbox with a simple RegularExpressionValidator set to not accept more than 1000 characters. I'm using the expression ".{1,1000}" w/o the quotes and I thought this would work. The DB table for this Column is set to varchar(1000). This works fine as long as I keep typing and it's under 1000 characters, but as soon as I hit the RETURN key...
2
2420
by: voxiac | last post by:
Could someone tell me why: Fails with message: Traceback (most recent call last): File "<pyshell#12>", line 1, in <module> re.compile('\\dir\\(file)') File "C:\Python25\lib\re.py", line 180, in compile return _compile(pattern, flags) File "C:\Python25\lib\re.py", line 233, in _compile
3
2418
by: =?Utf-8?B?c2JwYXJzb25z?= | last post by:
I have a scenario where a string is sent in chunks to my app. I need to be able to identify certain tags in this partial string as it arrives. eg <DALFile>xxxxxxxxx</DALFile> I need to be able to have a regex that will capture the start, middle and end of this file based on the tags. The problem is that the end tag may not always be present, and the content (xxxxxxx in this case) may contain carriage returns.
1
874
by: alexvorn2 | last post by:
Hi!, how to get the text that is between < and if it's length is more that 10 characters , text contains this: < to select this text <to select this text too> <thisnot
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10255
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10036
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9092
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7582
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6815
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.