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

Beanshell string manipulation

Hi All,

I'm newwith beanshell and i need to write a script that extracts an information from a string and if possible returns another string with the extracted pattern inside.
for example I have in inputs something like this:
<ns2:runResponse xmlns:ns2="http://soaplab.org/typedws" xmlns:ns3="http://ebi.ac.uk/fproml">[phylogeny_molecular_sequence.fproml]_797619cb.12900bfceba._650</ns2:runResponse>

what i want to extract is the id between > and < , in this case :
[phylogeny_molecular_sequence.fproml]_797619cb.12900bfceba._650
that is the only part that changes everytime.
After that I would obtain a string with that id a new string like:
<jobId xmlns="http://soaplab.org/typedws"><jobId xmlns="">[phylogeny_molecular_sequence.fproml]_797619cb.12900bfceba._650</jobId></jobId>

I tried to use the code in this way:

Expand|Select|Wrap|Line Numbers
  1. import java.util.regex.Pattern;
  2. import java.util.regex.Matcher;
  3.  
  4. StringBuffer temp = new StringBuffer();
  5. String information="";
  6. // regular expression to extract only the sequence description
  7. Pattern pattern = Pattern.compile ("([phylogeny_molecular_sequence.fproml])(...........................)*(</ns2:runResponse>)");
  8. Matcher matcher = pattern.matcher(inputs);
  9.  
  10. while(matcher.find()){
  11.     information=matcher.group(2);
  12.     temp.append(information);
  13. }
  14.  
  15. // Output sequence description
  16. String result = temp.toString();
but probably there is a smarter method to extract the same info,
and using something like
String result = temp.toString("<jobId xmlns=\"http://soaplab.org/typedws\"><jobId xmlns=\"\">" + information + "</jobId></jobId>");
to recreate the new output string doesn't work

thank you for any help
regards!
Jun 16 '10 #1
0 1567

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

Similar topics

3
by: siddhartha mulpuru | last post by:
We have some rows that we need to do some tricky string manipulation on. We have a UserID column which has userid entries in the format firstname.lastname and i need to change each entry to...
9
by: mjakowlew | last post by:
Hi, I'm trying to use some string manipulation from a file's path. filepath='c:\documents\web\zope\file.ext' I need to extract everthing after the last '\' and save it. I've looked around...
4
by: Jim McGivney | last post by:
Does anyone know of a concise article that covers string manipulation, such as insert, join, pad, etc. Thanks, Jim
7
by: John A Grandy | last post by:
what are the preferred VB.NET analogues for IsNumeric() and Len() and CInt() & similar string-manipulation functions in VB6
4
by: WaterWalk | last post by:
Hello, I'm currently learning string manipulation. I'm curious about what is the favored way for string manipulation in C, expecially when strings contain non-ASCII characters. For example, if...
5
by: Cleverbum | last post by:
I'm not really accustomed to string manipulation and so I was wondering if any of you could be any help i speeding up this script intended to change the format of some saved log information into a...
5
by: Niyazi | last post by:
Hi, Does anyone knows any good code for string manipulation similar to RegularExpresion? I might get a value as string in a different format. Example: 20/02/2006 or 20,02,2006 or ...
3
by: crprajan | last post by:
String Manipulation: Given a string like “This is a string”, I want to remove all single characters( alphabets and numerals) like (a, b, 1, 2, .. ) . So the output of the string will be “This is...
3
by: frankeljw | last post by:
I have 2 Java strings 1st String is a series of names, colons, and numbers ie) Name1:13:Name2:4526:Name3:789:Name4:3729:Name5:6:Name6:44 2nd String is a name ie) Name2 I need to get the...
1
by: adam bob | last post by:
Hello, I'm struggling with an image mechanism I'm trying to build which basically manipulates a URL string. This is the sort URL that is gained from an InfoPath form ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
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...

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.