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

exttracting the name from the string which i read from file

I read the following line from a file

Expand|Select|Wrap|Line Numbers
  1.  <th colspan="2"><font color="Brown">ABINAYA N</font></th>
in this line i want to extract name of the student (ABINAYA N here) how can i do that?

i will read this line for various 95 students where the students name may differ say(KARTHIK PRASATH K,KEERTHANA N,AJITH M)

how can i extract name of the students alone???

pls help me as soon as possible

advance thanks to you..
Sep 19 '08 #1
10 1327
JosAH
11,448 Expert 8TB
Read the API documentation for the Pattern and Matcher classes.
Compile a Pattern with the regular expression "\\>([^>]+)\\<" and match for
group 1 start and end boundaries.

kind regards,

Jos
Sep 19 '08 #2
I read the following line from a file

Expand|Select|Wrap|Line Numbers
  1. <th colspan="2"><font color="Brown">ABINAYA N</font></th>
in this line i want to extract name of the student (ABINAYA N here) how can i do that?

i will read this line for various 95 students where the students name may differ say(KARTHIK PRASATH K,KEERTHANA N,AJITH M)

how can i extract name of the students alone???

pls help me as soon as possible

advance thanks to you.

pls explain with some code
pls pls pls
Sep 19 '08 #3
JosAH
11,448 Expert 8TB
Hi, I removed your other identical thread. I also gave you the solution to your
problem: create a Pattern given the regexp I showed you; have the Pattern
create a Matcher and find the start() and end|() boundaries of group #1.
All you have to do is read the API documentation now.

kind regards,

Jos (moderator)
Sep 20 '08 #4
Nepomuk
3,112 Expert 2GB
As an alternative to Jos' suggestion, you could work with the String.substring() method, although regular expressions (the things with Patterns and Matchers) would be much more elegant.

Greetings,
Nepomuk
Sep 21 '08 #5
JosAH
11,448 Expert 8TB
As an alternative to Jos' suggestion, you could work with the String.substring() method
Which brings you back to exactly the original problem: what are the boundaries
of that substring?

kind regards,

Jos
Sep 21 '08 #6
Nepomuk
3,112 Expert 2GB
Which brings you back to exactly the original problem: what are the boundaries of that substring?
String.indexOf(...) (and related methods) should be quite helpful finding those.

Greetings,
Nepomuk
Sep 21 '08 #7
JosAH
11,448 Expert 8TB
String.indexOf(...) (and related methods) should be quite helpful finding those.

Greetings,
Nepomuk
Sure, but the substring() method doesn't help a bit; it can only extract the
result from the string.

kind regards,

Jos
Sep 22 '08 #8
Nepomuk
3,112 Expert 2GB
Sure, but the substring() method doesn't help a bit; it can only extract the result from the string.
Correct me if I'm wrong, but
in this line i want to extract name of the student (ABINAYA N here) how can i do that?
suggests, that extracting the result from the string is part of the process. ^^

Greetings,
Nepomuk
Sep 22 '08 #9
JosAH
11,448 Expert 8TB
Correct me if I'm wrong, but suggests, that extracting the result from the string is part of the process. ^^
Ah, so to questions like "I want to <fronobulax> my database and <mumble>
them and show the results to the user" you answer: System.out.println() because
that method is part of the process. Big fun.

kind regards,

Jos
Sep 22 '08 #10
Nepomuk
3,112 Expert 2GB
Ah, so to questions like "I want to <fronobulax> my database and <mumble> them and show the results to the user" you answer: System.out.println() because that method is part of the process. Big fun.
No, but answering: "You can use the System.out.println() method for the actual showing-part." would be correct. And I just said: "You can work with the String.substring() method." ^^

As I said in my initial post, your solution is much more elegant and if possible should be preferred. But I thought, I'd offer a second option and let the OP think about the two.

Greetings,
Nepomuk
Sep 22 '08 #11

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

Similar topics

8
by: Fu Bo Xia | last post by:
the java.lang.Object.forName method takes a java class name and returns a Class object associated with that class. eg. Class myClass = Object.forName("java.lang.String"); by if i only know the...
14
by: spike | last post by:
Im trying to write a program that should read through a binary file searching for the character sequence "\name\" Then it should read the characters following the "\name\" sequence until a NULL...
0
by: karunakar | last post by:
Hi All I am not able to read the class name I want read the particular class name string path = System.Configuration.ConfigurationSettings.AppSettings; string className = path + ".User";...
4
by: Jason | last post by:
I need to open a file for reading, but I only know part of it's name. The file I want to read is in the format of xxx-yyyy-zzz.EXT The last three digits of the file name are different on each...
3
by: Anup Daware | last post by:
Hi Group, I am facing a strange problem here: I am trying to read xml response from a servlet using XmlTextWriter. I am able to read the read half of the xml and suddenly an exception:...
0
by: =?Utf-8?B?U2ltb25EZXY=?= | last post by:
Hi All I would like to install the same Windows Service project on the same server under different names, one for each customer. I have been able to do it but I would like an expert opinion as...
4
by: lilyumestar | last post by:
I have project I have to do for class. We have to write 4 different .java files. Project2.java HouseGUI.java House.java HouseSorting.java I already finish House.java and I need to work on...
1
by: khore | last post by:
Hi Sorry I have to post another thread be4 leaving to the uni! I have a problem with file system. I have a phonebook service with has 2 methods: Set: adds new items to phone book lookup:...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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,...

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.