We help IT Professionals succeed at work.

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

lapucca
lapucca asked
on
180 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.
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Please provide the source text to match against and what exactly you want to match in that source text.
Please be elaborate on your problem.

Author

Commented:
The source text that got the error is "*G".
I group all the Gs together and named as gn.  Thank you.

Author

Commented:
The source text ;*' means wildcard just like RE.
CERTIFIED EXPERT

Commented:
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.

Author

Commented:
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.
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Ahh, that would be perfect, (.*)(?<gn>.)
Thank you.
CERTIFIED EXPERT

Commented:
Thanks for the question and the points.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.