473,509 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get the first word from a given string...

parajaganesh
17 New Member
How to get the first word from a given string in perl...
Oct 12 '07 #1
4 11207
KevinADC
4,059 Recognized Expert Specialist
The best way to get help on this forum with your questions is to post the code you have written so far to try and accomplish whatever it is you are doing. Posting a requirement with no code makes it seem like you are too lazy or unwilling to even try it yourself first, epecially when the question is such an easy one.

Beginning Perl
Oct 12 '07 #2
anjigorantla
8 New Member
How to get the first word from a given string in perl...
Try this code, and modify as u required. i think this will enough for ur doubt.

$a="flintstones husband fred pal barney wife wilma pet dino";
if ($a) {
$a=~/^(.*?)\s/;
print $1;
}
Oct 13 '07 #3
KevinADC
4,059 Recognized Expert Specialist
Try this code, and modify as u required. i think this will enough for ur doubt.

$a="flintstones husband fred pal barney wife wilma pet dino";
if ($a) {
$a=~/^(.*?)\s/;
print $1;
}
We prefer that people show some effort before doing their code/work for them.
Oct 13 '07 #4
Xmassey
6 New Member
I would split each word using the space between each word as he splitter. Then I would place the shift of the new array into a scaler.
Oct 13 '07 #5

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

Similar topics

20
11272
by: hagai26 | last post by:
I am looking for the best and efficient way to replace the first word in a str, like this: "aa to become" -> "/aa/ to become" I know I can use spilt and than join them but I can also use regular...
7
13975
by: zjut | last post by:
I need to implement the method : round(String name, int index) The given string maybe the every type of float type, ( the msdn given the regax is that : integral-digits]exponential-digits]) ...
5
2771
by: deko | last post by:
Is there an accepted or standard way to get a unique name given a string and the collection in which it needs to be unique? Should I use a HashTable? Other options? Here's a first crack: ...
2
6131
by: shapper | last post by:
Hello, I want to remove the first word of a string. For example: MyString = "Hello World! How are you?" I need to create 2 string: MyString1 = "Hello"
2
12048
by: Kelly B | last post by:
I tried to write a code which would reverse the order of words in a given string. I.e if Input String=The C Programming Language Output String=Language Programming C The Here is the code...
0
1927
by: wildman | last post by:
What's the easiest way to return the first word from a string in vb.net? thanks for any help or information.
4
2390
MrPickle
by: MrPickle | last post by:
I am tokenizing a line using a stringstream and a vector but the stringstream seems to be repeating the first word, here's my code: std::stringstream ss; std::vector<std::string> LineVec;...
2
1824
by: whodgson | last post by:
The following code accepts a string from the user and swaps the first and last letters in each word. It prints out the original string incorrectly by dropping off the first letter of the first word....
0
7233
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
7135
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
7410
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
7067
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...
1
5060
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
4729
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...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
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 ...
0
440
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.