Solved

Regex Pattern for  33/4  61/2  11/8 types

Posted on 2007-03-20
5
179 Views
Last Modified: 2010-04-23
.net 2003

Regex Update to look at these patterns
FIND      REPLACE
11/2      1`1/2
11/4      1`1/4
11/8      1`1/8
21/2      2`1/2
21/4      2`1/4
21/8      2`1/8
31/2      3`1/2
31/4      3`1/4
31/8      3`1/8
33/4      3`3/4

or a regex specifically for these patterns examples


0
Comment
Question by:fordraiders
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 300 total points
ID: 18762130
Hi fordraiders,

You could use something like this....

Regex.Replace("33/4", "(\d)(\d)/(\d)", "$1`$2/$3")

...which will return 3`3/4.  It finds 2 numbers, then a slash, then another number.

Regards,

Wayne
0
 
LVL 3

Author Comment

by:fordraiders
ID: 18763218
What if there is a space before or after the fraction .?
<space>33/4<space>

0
 
LVL 63

Assisted Solution

by:Fernando Soto
Fernando Soto earned 200 total points
ID: 18763780
Hi fordraiders;

Adding to Wayne's solution.

    Regex.Replace(inputString, "\s(\d)(\d)/(\d)\s", "$1`$2/$3")

Fernando
0
 
LVL 3

Author Comment

by:fordraiders
ID: 18763850
Thanks Fernanado,

0
 
LVL 3

Author Comment

by:fordraiders
ID: 18763873
Fernanado, By the way...
I have posted a new question...

Trying to Update a previous solution regarding this same subject..
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22107923.html?sfQueryTermInfo=1+strfractionreplac
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

735 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