Solved

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

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

19 Experts available now in Live!

Get 1:1 Help Now