?
Solved

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

Posted on 2007-03-20
5
Medium Priority
?
185 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
  • 3
5 Comments
 
LVL 48

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 1200 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 64

Assisted Solution

by:Fernando Soto
Fernando Soto earned 800 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

807 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