473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Another regex question

Hello,
I'm trying to regex an expression like this:

var1: val11 val12 ... val1N var2: val21 val22 ... val2M ... varI: valI1 ... valIJ

to get a something like this:

var1: val11 val12 ... val1N
var2: val21 val22 ... val2M
..
..
..
varI: valI1 ... valIJ

for example a multiple array.

Any ideas...? Thanks,

Sebastián Araya
Jul 17 '05 #1
2 1749
We need a more detailed example than that in order to be able to help you. I
can't see any pattern in the examples you gave us so it's very likely that
the expression we would develope would be wrong.

Either way.. this might be what you're looking for:

<?php
$string = "var1: val11 val12 ... val1N var2: val21 val22 ... val2M ... varI:
valI1 ... valIJ";
$new_string = ereg_replace(" ([a-zA-Z0-9]+)\:", "\n\\1:", $string);
echo $new_string;
?>

--
Erik Andersson ( E.N.E IT - Australia )
http://www.eneit.com/
- Australian, high quality web hosting from AU$4.95, all features included.

"Sebastian Araya" <ar*****@numisys.com.ar> wrote in message
news:67**************************@posting.google.c om...
Hello,
I'm trying to regex an expression like this:

var1: val11 val12 ... val1N var2: val21 val22 ... val2M ... varI: valI1 .... valIJ
to get a something like this:

var1: val11 val12 ... val1N
var2: val21 val22 ... val2M
.
.
.
varI: valI1 ... valIJ

for example a multiple array.

Any ideas...? Thanks,

Sebastián Araya

Jul 17 '05 #2
Thank you!

Although I can't explain myself, your solution is brilliant.

Thanks and Happy New Year!

Sebastián Araya
http://www.numisys.com.ar/

"Erik Andersson" <er**@wcttour.com> wrote in message news:<3f*********************@uq-127creek-reader-02.brisbane.pipenetworks.com.au>...
We need a more detailed example than that in order to be able to help you. I
can't see any pattern in the examples you gave us so it's very likely that
the expression we would develope would be wrong.

Either way.. this might be what you're looking for:

<?php
$string = "var1: val11 val12 ... val1N var2: val21 val22 ... val2M ... varI:
valI1 ... valIJ";
$new_string = ereg_replace(" ([a-zA-Z0-9]+)\:", "\n\\1:", $string);
echo $new_string;
?>

--
Erik Andersson ( E.N.E IT - Australia )
http://www.eneit.com/
- Australian, high quality web hosting from AU$4.95, all features included.

Jul 17 '05 #3

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

Similar topics

5
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...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
2
by: Tim Conner | last post by:
Hi, Thanks to Peter, Chris and Steven who answered my previous answer about regex to split a string. Actually, it was as easy as create a regex with the pattern "/*-+()," and most of my string...
6
by: Du Dang | last post by:
Text: ===================== <script1> ***stuff A </script1> ***more stuff <script2> ***stuff B
17
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
4
by: Chris | last post by:
Hi Everyone, I am using a regex to check for a string. When all the file contains is my test string the regex returns a match, but when I embed the test string in the middle of a text file a...
7
by: Extremest | last post by:
I am using this regex. static Regex paranthesis = new Regex("(\\d*/\\d*)", RegexOptions.IgnoreCase); it should find everything between parenthesis that have some numbers onyl then a forward...
5
by: redamazon200 | last post by:
I am looking for a way to copy a pattern (letter 'A' in the following example) to another string. string str1 = "1111AAAA111111AA"; string str2 = "1111000000001111"; After the copy str2...
3
by: =?Utf-8?B?bWFnZ2ll?= | last post by:
hi, I've been working getting a file parsed out using Regex. There's something I don't understand. When I define the pattern for my fields in my file, I am telling regex to grab those fields (...
6
by: | last post by:
Hi all, Sorry for the lengthy post but as I learned I should post concise-and-complete code. So the code belows shows that the execution of ValidateAddress consumes a lot of time. In the test...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.