• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

Regex Pattern Solution not working

.net 2003
Access 2003

Trying re-due   regexes to work on the following patterns



' looking for fuse  combinations
temp = Regex.Replace(temp, "\s(TRS|FRSR|FRNR|REN|RES)\s", " $1 ")
temp = Regex.Replace(temp, "(\d+)(TRS|FRSR|FRNR|REN|RES)\s", "$1 $2 ")


Before                     After
Column A                 Column B
GDA1.6A            GDA16A
KAX10 / FWX10      KAX10FWX10
KAX15 / FWX15      KAX15FWX15
KAX20 / FWX20      KAX20FWX20
KAX30 / FWX30      KAX30FWX30
KTK-R25            KTKR25
FNM1/2            FNM12
FNQ1-1/4                      FNQ114
FNQ1-1/2                      FNQ112
FNQR1/2            FNQR12
LP-CC2            LPCC2
LP-CC3            LPCC3
LP-CC6            LPCC6
LP-CC12            LPCC12
LP-CC15            LPCC15
LP-CC17-1/2      LPCC1712
LP-CC30            LPCC30
AGC1/8            AGC18
AGC1/4            AGC14
AGC1-1/2                      AGC112
AGC2-1/2                      AGC212
ABC1            ABC1
ABC-2            ABC2
LPJ1-1/2SP      LPJ112SP
LPJ17-1/2SP      LPJ1712SP
FRN-R1            FRNR1
FRN-R2            FRNR2
FRN-R2-1/2      FRNR212
FRN-R3            FRNR3
FRN-R5            FRNR5
FRN-R6            FRNR6
FRN-R8            FRNR8
FRN-R10            FRNR10
FRN-R12            FRNR12
FRN-R15            FRNR15
FRN-R20            FRNR20
FRN-R25            FRNR25
FRN-R30            FRNR30
FRN-R40            FRNR40
FRS-R4            FRSR4
FRS-R5            FRSR5
FRS-R6            FRSR6
FRS-R6-1/4      FRSR614
FRS-R7-1/2      FRSR712
FRS-R8            FRSR8
FRS-R10            FRSR10
FRS-R12            FRSR12
FRS-R15            FRSR15
FRS-R17-1/2      FRSR1712
FRS-R20            FRSR20
FRS-R25            FRSR25
FRS-R30            FRSR30
FRS-R40            FRSR40
FRS-R45            FRSR45
FRS-R60            FRSR60
FRS-R70            FRSR70
FRS-R80            FRSR80
FRS-R90            FRSR90
FRS-R100                      FRSR100
FRS-R125                      FRSR125
MDL-1/8            MDL18
MDL-1/4            MDL14
MDL-1/2            MDL12
MDL-3/4            MDL34
MDL-1            MDL1
MDL-1-1/2      MDL112
MDL-6            MDL6
MDL-10            MDL10

Thanks
fordraiders

0
Fordraiders
Asked:
Fordraiders
1 Solution
 
ddrudikCommented:
Explain what you want to match and/or replace exactly.
0
 
Fernando SotoCommented:
Are you saying

Giving these value      Return these value ?
KAX10 / FWX10           KAX10FWX10
KAX15 / FWX15           KAX15FWX15
KAX20 / FWX20           KAX20FWX20
KAX30 / FWX30           KAX30FWX30
0
 
ozoCommented:
And what do you want the regexes to do that is not working?

Do you want
Regex.Replace(temp, "[^A-Z0-9]", "")
0
Technology Partners: 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!

 
FordraidersAuthor Commented:
example from above:

see this           becomes this
FRS-R7-1/2      FRSR712
FRS-R8            FRSR8
FRS-R10            FRSR10
FRS-R12            FRSR12
FRS-R15            FRSR15


Taking dashes and

If the pattern starts with   FRSR   TAKE OUT A SLASH / OR DASH - OR  .

FRN-R1            FRNR1
FRN-R2            FRNR2
FRN-R2-1/2      FRNR212
FRN-R3            FRNR3
FRN-R5            FRNR5

strats with  FRN

Thanks
fordraiders



0
 
FordraidersAuthor Commented:
fernando ,

Are you saying

Giving these value      Return these value ?
KAX10 / FWX10           KAX10FWX10
KAX15 / FWX15           KAX15FWX15
KAX20 / FWX20           KAX20FWX20
KAX30 / FWX30           KAX30FWX30


yes
0
 
ddrudikCommented:
Replace [-/] with string.empty.
0
 
ddrudikCommented:
ignore my post, ozo read it right.
0
 
FordraidersAuthor Commented:
ozo,

will this get rid of the dashes and slashes


And what do you want the regexes to do that is not working?

Do you want
Regex.Replace(temp, "[^A-Z0-9]", "")


0
 
FordraidersAuthor Commented:
??
0
 
ddrudikCommented:
fordraiders, ozo's pattern will remove any character that is not A-Z or 0-9, is that what you wanted?
0
 
FordraidersAuthor Commented:
Thanks
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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now