swaggerbox
02-16-2013, 03:54 AM
Paul did an excellent in getting the regex pattern in my previous post (http://www.vbaexpress.com/forum/showthread.php?t=45197).
Find = (<[0-9.]{1,}>) part[s ]{1,2}of (<*> ink)
Replace = \2 (\1)
I want something similar but this time, the pattern is a bit variable. There is a mixture of whole numbers and decimals, and numbers could go up the thousands level. Could anyone help me with this?
Original: (input)
40-120 parts of isoleucine, 45-135 parts of leucine, 76.5-229.5 parts of lysine hydrochloride, 21.5-64.5 parts of methionine, 35-105 parts of phenylalanine, 40-120 parts of valine, 30-90 parts of threonine, 39-117 parts of arginine, 23-69 parts of histidine, 37.5-112.5 parts of glycine, 50-150 parts of aspartate, 900-2700 parts of dried mushroom, 750-2250 parts of medlar and 250-750 parts of liquorice.
Modified: (Desired output)
isoleucine (40-120), leucine (45-135), lysine hydrochloride (76.5-229.5), methionine (21.5-64.5), phenylalanine (35-105), valine (40-120), threonine (30-90), arginine (39-117), histidine (23-69), glycine (37.5-112.5), aspartate (50-150), dried mushroom (900-2700), medlar (750-2250) and liquorice (250-750).
Find = (<[0-9.]{1,}>) part[s ]{1,2}of (<*> ink)
Replace = \2 (\1)
I want something similar but this time, the pattern is a bit variable. There is a mixture of whole numbers and decimals, and numbers could go up the thousands level. Could anyone help me with this?
Original: (input)
40-120 parts of isoleucine, 45-135 parts of leucine, 76.5-229.5 parts of lysine hydrochloride, 21.5-64.5 parts of methionine, 35-105 parts of phenylalanine, 40-120 parts of valine, 30-90 parts of threonine, 39-117 parts of arginine, 23-69 parts of histidine, 37.5-112.5 parts of glycine, 50-150 parts of aspartate, 900-2700 parts of dried mushroom, 750-2250 parts of medlar and 250-750 parts of liquorice.
Modified: (Desired output)
isoleucine (40-120), leucine (45-135), lysine hydrochloride (76.5-229.5), methionine (21.5-64.5), phenylalanine (35-105), valine (40-120), threonine (30-90), arginine (39-117), histidine (23-69), glycine (37.5-112.5), aspartate (50-150), dried mushroom (900-2700), medlar (750-2250) and liquorice (250-750).