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

Regex in c# and Java

1
Have a query regarding Regular expressions...

Java

int PARSE_AUTHORITY_PORT = 3;
String input = "2089 krameria st., denver, co";
String expression = "/([0-9]+) ([^,]+), ([^,]+), (.+)/";
Perl5Util authorityMatcher = new Perl5Util();

if (authorityMatcher.match(expression, input))
{
String port = authorityMatcher.group(PARSE_AUTHORITY_PORT);
}

gives denver as output

where as in C#

String input = "2089 krameria st., denver, co";
String expression = "/([0-9]+) ([^,]+), ([^,]+), (.+)/";
Regex reg = new System.Text.RegularExpressions.Regex(expression, RegexOptions.IgnoreCase);
Match match = reg.Match(input);
if (match.Success)
{

GroupCollection grpc = match.Groups;
string port=match.Groups[3].ToString());
}

doesnt give me the desired out put if i try "([0-9]+) ([^,]+), ([^,]+), (.+)" instead of
"/([0-9]+) ([^,]+), ([^,]+), (.+)/" it gives me the same result. but my source files have lot of expressions and it's diffcult to go and check everwhere where exactly it fails.... Can nybdy helps me out .
Jul 23 '07 #1
0 836

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

Similar topics

5
by: Andrew Dixon | last post by:
Hi Everyone. Ok I have a problem getting the following regex to work in Java. <script*>(.|\r|\n)+?</script> It works fine in EditPad Pro but in Java it causes the following error message...
5
by: Blue Ocean | last post by:
In short, it's not working right for me. In long: The program is designed to read numbers from an accumulator and speak them out loud. Unfortunately, the class that contains the method to...
1
by: Alejandro Narancio | last post by:
Hi for everyone, i need to parse a text and i need to found a text like this: <objInformation name="<%=Property.name%> version="1"> I try to parse this with this pattern but don't work: ...
4
by: Demetri | last post by:
Lets pretend you have a string array and each element is a sentence. Two of those elements read as follows: 1. The fox escaped from the hound. 2. The fox almost escaped. Now lets say you loop...
16
by: Andrew Baker | last post by:
I am trying to write a function which provides my users with a file filter. The filter used to work just using the VB "Like" comparision, but I can't find the equivilant in C#. I looked at...
10
by: Mokita | last post by:
Hello, I am working with Taverna to build a workflow. Taverna has a beanshell where I can program in java. I am having some problems in writing a script. I want to extract information from a...
3
by: Jonathan Lukens | last post by:
I am in the last phase of building a Django app based on something I wrote in Java a while back. Right now I am stuck on how to return the matches of a regular expression as a list *at all*, and...
0
by: vmysore | last post by:
I am trying to get all the columns selected within a SQL query (including the sub selects). When the code hits matcher.find(). i get the following exception: Exception in thread "main"...
4
by: sukatoa | last post by:
This was my first time to encouter this kind of exception.... that exception appears when i invoked the the method below. private final String encrypting(String enc){ int...
9
by: kummu4help | last post by:
can anyone give me a regex to validate the password with following conditions hope i am clear. i tried with ctype_alnum() function in php but it is accepting if all characters or either...
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: 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: 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...
0
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...

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.