473,511 Members | 15,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

deleting characters after comma

I have a string:

"WorldWatch, Tokyo"

Is there anyway I can delete everything after the comma including the
comma itself? Keep in mind that everything atfer the comma is
generated dynamically!

Thanks!
Aug 5 '08 #1
3 2048
In article <1b01c7ba-d6e8-47fe-9af7-
b1**********@m36g2000hse.googlegroups.com>, says...
I have a string:

"WorldWatch, Tokyo"

Is there anyway I can delete everything after the comma including the
comma itself? Keep in mind that everything atfer the comma is
generated dynamically!
Read the manual on the functions stripos and substr.

Geoff M
Aug 5 '08 #2
On 5 ago, 20:04, cosmicsta...@gmail.com wrote:
>
"WorldWatch, Tokyo"

Is there anyway I can delete everything after the comma including the
comma itself? Keep in mind that everything atfer the comma is
generated dynamically!

Thanks!
as Geoff said, to do that, you should use strpos and substring
an example:
$str = 'WorldWatch, Tokyo';
$positionOfTheComma = strpos($str,',');
$strWithoutTheComma = substr($str, 0, $positionOfTheComma);

Aug 6 '08 #3
On Aug 6, 12:12 am, Geoff Muldoon <geoff.muld...@trap.gmail.com>
wrote:
In article <1b01c7ba-d6e8-47fe-9af7-
b15575370...@m36g2000hse.googlegroups.com>, says...
I have a string:
"WorldWatch, Tokyo"
Is there anyway I can delete everything after the comma including the
comma itself? Keep in mind that everything atfer the comma is
generated dynamically!

Read the manual on the functions stripos and substr.

Geoff M
...or strtok, preg_match, explode....actually, read all the manual.

C.
Aug 6 '08 #4

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

Similar topics

17
43416
by: Behrang Dadsetan | last post by:
Hi all, I would like deleting specific characters from a string. As an example, I would like to delete all of the '@' '&' in the string 'You are ben@orange?enter&your&code' so that it becomes...
5
23332
by: Jay Chan | last post by:
I am trying to use a command line program to run a stored procedure that generates output in a comma-delimitted format. Somehow, ISQL or OSQL always wrap the lines at 256 characters. I believe this...
3
1396
by: Thaynann | last post by:
is there a way to delete a block of text i have started by looking for the speicific line of text that starts the block by looking for teh index of it...but i cannot figure out out to remove...
0
1999
by: Patrick.O.Ige | last post by:
I have a datagrid with checkboxes.. When a user clicks one check box and clicks the delete button it deletes that ROw. There another situation when a user clicks multiple rows so i had to loop...
4
3017
by: vvenk | last post by:
Hello: I have a string, "Testing_!@#$%^&*()". It may have single and double quotations as well. I would like to strip all chararcters others than a-z, A-Z, 0-9 and the comma. I came across...
2
1496
by: ptq2238 | last post by:
Hi, I've been experimenting some more with strings, I've written some code where I want to test to see if a certain character char_a is in the testlist string. Simple enough. The problem is when...
2
2352
by: chike_oji | last post by:
Hello, I am displaying data retrieved from a database as a httpresponse in a webform. I noticed that some characters such as the comma (,), display as special characters in the web browser...
28
1055
by: SL | last post by:
How can I compute with the integer values of characters in python? Like 'a' + 1 equals 'b' etc
1
1813
by: Brock | last post by:
Thanks in advance... I have a string that I'm building that needs to write to a file the last name, first name and middle initial in this format with a maximum of 20 characters. Two examples: ...
0
7349
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
7417
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...
1
7074
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...
0
7506
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...
0
5659
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,...
1
5063
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...
0
3219
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
445
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...

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.