0

In C I use sscanf to split a string

sscanf(In, "%2d%2d%c", &lat_deg, &lat_min, &lat_hem);

How to I do this in razor with no delimeters? Easy to do with delimeters but all i know is the size of the string and it needs to be split at certain spots.

The string I am trying to spilt has the following format 342050S and needs to be split into 4 parts 34 20 50 and S. I tried using a Regex example I found online but it didn't like being in my cshtml code... didn't seem to know what it was...

Is there something better than using str.Substring() on the input?

I am very new to this from a C background so thank you for your help.

tj26
  • 197
  • 1
  • 10
  • Please show some code what you tried. Typically there's no problem using regular expressions also in cshtml, if you do it correctly ... Otherwise you can always use the Substring method to extract certain parts of a string – derpirscher Aug 23 '21 at 06:49
  • Would be a job for RegEx => `(\d{2})(\d{2})(\d{2})(\w{1})` – Oliver Aug 23 '21 at 07:23
  • Thank you. Oliver how using RegEx do I get each into a variable like the in sscanf or can it be read into a string array? RegEx is a much nicer solution than substring – tj26 Aug 24 '21 at 06:41

0 Answers0