Solved

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

Posted on 2007-03-20
5
173 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 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 62

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now