?
Solved

What would RE look like for matching just the last character of an input?

Posted on 2007-10-03
9
Medium Priority
?
166 Views
Last Modified: 2010-04-15
Hi, I want to match the last character of a named expression but I'm getting exception error saying Quantifier {x,y} for following nothing.
My RE: *(?<gn>\w)

How can I correct this?  Thank you.
0
Comment
Question by:lapucca
  • 4
  • 4
9 Comments
 
LVL 27

Expert Comment

by:ddrudik
ID: 20006789
Please provide the source text to match against and what exactly you want to match in that source text.
0
 

Expert Comment

by:sjith2000
ID: 20006862
Please be elaborate on your problem.
0
 

Author Comment

by:lapucca
ID: 20006977
The source text that got the error is "*G".
I group all the Gs together and named as gn.  Thank you.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:lapucca
ID: 20006982
The source text ;*' means wildcard just like RE.
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 20007009
I don't understand what you are asking for; if you need a regular expression to make some source text I assume you have some source text sample, if not I cannot help.
0
 

Author Comment

by:lapucca
ID: 20007438
In my C# application I am asking users to enter limited characters that I then translate into a regular expression and use it to find matches in a Ado.net datatable and use that match result to find another match in another datatabel.  It's kind of complicated but that is the design requirment.
If they enter "*G" then I need to find in the datatabel that matches the last character
For example, abcdef from table 1 would be matched into 12353283082f of the 2nd table.  I just need help in how to translate the wildcard and to only match the last char of a name group in RE.
Would it be something like
(\w)*(?<gn>\w)
Thank you.
0
 
LVL 27

Accepted Solution

by:
ddrudik earned 2000 total points
ID: 20008173
Depends what the last character might be, to include all chars. (except \n unless option-enabled):
(.*)(?<gn>.)

To use your \w:
(\w*)(?<gn>\w)
0
 

Author Comment

by:lapucca
ID: 20008314
Ahh, that would be perfect, (.*)(?<gn>.)
Thank you.
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 20008747
Thanks for the question and the points.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question