How to check if variable contains roman numerals between 1-100?

Hi,

I have an activity to query customer address from the database and then write it into word. The data from my database are all in upper case, for example :

NORTH STREET VIII BLOCK C

I am using this expression to make it into propercase :

StrConv(address_street,VbStrConv.ProperCase)

and this is the result I got :

North Street Viii Block C

The problem is, the roman numerals are converted into proper case too when the value should be VIII instead Viii. Is there any way to make the robot read if(address_street) contains roman numerals between 1-100 then replace it with proper numerals writing? I’m thinking of using dictionary but I don’t know how to make the robot read the roman numerals, or is there any better solution for it?

Hi,

Simply, we can convert word consists of I,V,X,L and C to upper case, as the following.

System.Text.RegularExpressions.Regex.Replace(yourString,"\b[IVXLC]+\b",Function(m) m.Value.ToUpper,System.Text.RegularExpressions.RegexOptions.IgnoreCase)

However this also converts word except roman numerals such as “Civic”, “Xi” etc. to upper.
If you cannot accept this limitation, need to consider more strict condition. (It might be necessary to create list of 100 pattern of roman numerals)

Regards,

1 Like

Hi,

Unfortunately it’s not gonna work because there’s another data containing Honda Vehicle like you mentioned (CIVIC, CRV, etc). So I can assume the solution given are not gonna work. But one thing I notice is the “yourString”

let’s say I put the yourString variable is address_street. Will the variable that store the vehicle data (let’s call it strVehicle) will be replaced into Upper case too? Thanks

Hi,

If “yourString” variable contains only address_street part and convert it using the above expression, it doesn’t affect to strVehicle.
The matter might be how to split to these items properly, I think.

Regards,

Ok that’s the #1 possibility. #2 possibility, if the address_street variable contains letter I,V,X,L,C, it will converted into uppercase too right?

HI,

The above expression converts word consists of only I,V,X,L,C to upper. For example “iv” is converted to “IV” but" iva" is not converted.

Regards,

Ok I tried this and it’s working. Thank you very much ! Let me try another test case to make it more sure

Hi,

FYI, according to the following, we might be able to write it more strict.

Can you try the following? This supports up to 4000.

System.Text.RegularExpressions.Regex.Replace(yourString,"\bM{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})\b",Function(m) m.Value.ToUpper,System.Text.RegularExpressions.RegexOptions.IgnoreCase)

Regards,

1 Like

Okay I understand this more. So it’s more accurate to the Romans Numeral and it will make the romans into Uppercase. 4000 is more than enough, thanks !!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.