?
Solved

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

Posted on 2007-03-20
5
Medium Priority
?
182 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 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 63

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

752 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