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

how to fetch specific text from inputed string using regex

Hi!
I want to fetch "name" as per the name of the journal.

<JOURNAL> name </JOURNAL>

name will be diff in diff files. I am reading file line by line and sending pattern
<JOURNAL>([-_\\w\\s])</JOURNAL> to match . it matches but it matches whole string.
I want within ( ) bracket as in perl we can get by $1 variable.

thanks in advance.
Jun 15 '07 #1
3 1987
JosAH
11,448 Expert 8TB
Hi!
I want to fetch "name" as per the name of the journal.

<JOURNAL> name </JOURNAL>

name will be diff in diff files. I am reading file line by line and sending pattern
<JOURNAL>([-_\\w\\s])</JOURNAL> to match . it matches but it matches whole string.
I want within ( ) bracket as in perl we can get by $1 variable.

thanks in advance.
You can do exactly the same in Java, i.e. $1 is the first 'capturing group' which
means the leftmost substring in parentheses.

kind regards,

Jos
Jun 15 '07 #2
You can do exactly the same in Java, i.e. $1 is the first 'capturing group' which
means the leftmost substring in parentheses.

kind regards,

Jos

can you give emaple how to write.
Jun 15 '07 #3
JosAH
11,448 Expert 8TB
can you give emaple how to write.
Have a look at the find() and group methods in the Matcher class.

Alternatively use the replaceAll method in the String class; it uses
a Pattern and a Matcher for its purpose so the replacement string can be the
"$1" pattern.

kind regards,

Jos
Jun 15 '07 #4

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

Similar topics

6
by: Tony C | last post by:
I'm writing a python program which uses regular expressions, but I'm totally new to regexps. I've got Kuchling's "Regexp HOWTO", "Mastering Regular Expresions" by Oreilly, and have access to...
5
by: nboutelier | last post by:
Scenario: you enter "foo bar" into a text field... Is it possible through javascript to select/highlight just "foo"? formObject.select() selects all. I need to select only part of the string....
0
by: Daniel Perron | last post by:
Hi, I was trying to use Galois.Net to specify code generators and I had to look for some text template tool to simplify the syntax. I was looking for something similar to the syntax of an...
5
by: D | last post by:
hi there , i want to do something fairly simple (well it was simple in PERL) using the replace function of Regex... but i cannot find the docs to help me on it... i want to use a regex to find a...
8
by: Richard Lionheart | last post by:
Hi All, I tried using RegEx, but the compiler barfed with "The type of namespace 'RegEx' could not be found. Prior to this, I had the same problem with MatchCollection, but discovered it's...
17
by: J.S. | last post by:
I have a text file with parameters like the following embedded in the text: @@TextBox1@@, @@TextBox2@@, etc. I know how to read this text file. However, I am trying to figure out how to...
24
by: garyusenet | last post by:
I'm working on a data file and can't find any common delimmiters in the file to indicate the end of one row of data and the start of the next. Rows are not on individual lines but run accross...
7
by: asenthil | last post by:
Hai to all, this is senthil... i'm now working in the field of VC++... i want to connect a mysql database... just now tried to retrieve rows from a simple mysql database by using VC++ My...
4
by: wildman | last post by:
RE: Replacing Text without changing case?? This code works great, but case has to be exact. Research.Text = Research.Text.Replace(textboxSearch.Text, "<b>" + textboxSearch.Text + "</b>") ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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

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.