473,322 Members | 1,431 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,322 software developers and data experts.

Cut text out from a string

I have a string : 420_million_people-(Softeware_Computer)/en

i want to have string cut like

string1 before -
string1 : 420_million_people

and

string2 before between ()
string2: Softeware_Computer

string3 after /
string3: en

please help me

below is the code i have try to use (Not working lol)

the string is come from a sql

Expand|Select|Wrap|Line Numbers
  1. $query = "SELECT tmw_page.page_title FROM tmw_page";
  2. $qry_result = mysql_query($query) or die(mysql_error());
  3. $result=mysql_query($query);
  4.     while($row = mysql_fetch_row($result))
  5.     {
  6.  
  7.         foreach($row as $values)
  8.         {
  9.  
  10.  
  11.             preg_match('/.*-/i', $values, $result);
  12.             echo ($result[0]);
  13.             echo("<br><br>$values2<br>");
  14.  
  15.  
  16.             list($junk, $good) = split('(', $string);
  17.             list($good, $junk) = split(')', $good);
  18.             echo $values;
  19.  
  20.         }
  21.     }
Nov 2 '08 #1
2 3923
Atli
5,058 Expert 4TB
Hi.

That regular expression isn't even close.
Check out the tutorial here to see how to use regular expressions.

This could be done by simply using the explode function.
Firstly, you would want to split the string using the "-" char.
Then, split the second part of that with the "/" char.
And finally, trim the ( and ) from the middle part.
Nov 2 '08 #2
Hi.

That regular expression isn't even close.
Check out the tutorial here to see how to use regular expressions.

This could be done by simply using the explode function.
Firstly, you would want to split the string using the "-" char.
Then, split the second part of that with the "/" char.
And finally, trim the ( and ) from the middle part.

Thank You for help
it work now
Thanks a lot
Nov 3 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Nikolay Petrov | last post by:
How can I convert DOS cyrillic text to Unicode
1
by: Darsin | last post by:
What i am doing is to pull the data from a CMS and import it to Word 2007 Beta and i also have to export the data from Word 2007 Beta back to that CMS. We have with us two Web Services of the CMS....
0
by: JosAH | last post by:
Greetings, Introduction Before we start designing and implementing our text builder class(es), I'd like to mention a reply by Prometheuzz: he had a Dutch version of the entire bible ...
0
by: JosAH | last post by:
Greetings, the last two article parts described the design and implementation of the text Processor which spoonfeeds paragraphs of text to the LibraryBuilder. The latter object organizes, cleans...
0
by: JosAH | last post by:
Greetings, welcome back; above we discussed the peripherals of the Library class: loading and saving such an instantiation of it, the BookMark interface and then some. This part of the article...
16
by: Wayne | last post by:
I've read that one method of repairing a misbehaving database is to save all database objects as text and then rebuild them from the text files. I've used the following code posted by Lyle...
3
by: SteveB | last post by:
I have posted this question in the Visual Basic 2005 and Visual Basic .Net 2005 discussion groups, also. Hi. I am developing an application/web page with VB.Net that will populate a SQL...
0
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.