473,586 Members | 2,702 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 2054
In article <1b01c7ba-d6e8-47fe-9af7-
b1**********@m3 6g2000hse.googl egroups.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...@gm ail.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';
$positionOfTheC omma = strpos($str,',' );
$strWithoutTheC omma = substr($str, 0, $positionOfTheC omma);

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...@m3 6g2000hse.googl egroups.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....actu ally, 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
43433
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 'benorange?enteryourcode'. So far I have been doing it like: str = 'You are ben@orange?enter&your&code' str = ''.join()
5
23349
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 has something to do with the column width switch (-w). But enlarging the column width to 800 characters max still doesn't help. The following is a...
3
1405
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 that text from the file..can anyone help me?
0
2004
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 throug the rows like so:- foreach (DataGridItem i in DataGrid1.Items) { CheckBox deleteChkBxItem = (CheckBox) i.FindControl ("DeleteRow"); if...
4
3022
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 the following snippet in the online help but the output does not change at all:
2
1502
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 testlist contains characters other than letters and numbers such as comma, full stop and double quotes. #include <stdio.h> #include <string.h> ...
2
2354
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 (Internet Explorer). It displays something like $^^% instead of a comma. Please how can I have the browser display the comma as it is from the...
28
1062
by: SL | last post by:
How can I compute with the integer values of characters in python? Like 'a' + 1 equals 'b' etc
1
1818
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: Brenda J Lanier Lanier,Brenda J ' note that this name is only 15 characters, with the space and comma, after formatting so I'm safe
0
7911
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...
0
7839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8200
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7954
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...
0
6610
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...
0
3836
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.