none
Matching ID's by Regex RRS feed

  • Question

  • Hello everyone,

    I want to check ID's using Regex

        Shared ReadOnly UniverseChrs As String = "IUMGAPCgTLcia"
        Shared ReadOnly Steam2Regex As Regex = New Regex("STEAM_(?<Universe>[0-4]):(?<AuthServer>[0-1]):(?<ID>[1-9][0-9]{0,9}$|^2147483647)", RegexOptions.Compiled Or RegexOptions.IgnoreCase)
        Shared ReadOnly Steam3Regex As Regex = New Regex("(?<Type>[" & UniverseChrs & "]):(?<Universe>[0-4]):(?<ID>[1-9][0-9]{0,9}$|^2147483647)(:(?<Instance>[1-9][0-9]{0,9}$|^2147483647))?", RegexOptions.Compiled)

    the ID's formats are

        '[U:1:4533645:093919]
        '[U:1:17309919]
        'U:1:254093919
        'U:1:354093:914739
        'STEAM_0:1:227046959
        'STEAM_1:0:358204935

    Steam2Regex seems to work, but Steam3Regex not.

    Anyone can help me with this?

    Thanks in advance.

    Saturday, May 25, 2019 11:49 AM

Answers

  • I think that

       (?<Type>[IUMGAPCgTLcia]):(?<Universe>[0-4]):(?<ID>[1-9][0-9]{0,9})(?::(?<Instance>[0-9]{1,10}))?

    matches all of U:1:254093919, U:1:354093:914739, [U:1:4533645:093919] and [U:1:17309919].

    • Marked as answer by Lersubem Sunday, May 26, 2019 6:08 AM
    Sunday, May 26, 2019 5:59 AM

All replies

  • Maybe you should remove ‘$’ and use ‘0-9’ instead of ‘1-9’ in the <Instance> part.

    Check this expression:

       (?<Type>[IUMGAPCgTLcia]):(?<Universe>[0-4]):(?<ID>[1-9][0-9]{0,9})(?::(?<Instance>[0-9]{1,10}))?

    and add missing parts.

    Saturday, May 25, 2019 4:43 PM
  • U:1:254093919, Seems to match, but U:1:354093:914739 not.

    and bot [U:1:4533645:093919] and [U:1:17309919] also don't match.

    I understand from the result that this part [1-9][0-9]{0,9}$|^2147483647 is correct since also Steam2Regex works

    Sunday, May 26, 2019 5:13 AM
  • I think that

       (?<Type>[IUMGAPCgTLcia]):(?<Universe>[0-4]):(?<ID>[1-9][0-9]{0,9})(?::(?<Instance>[0-9]{1,10}))?

    matches all of U:1:254093919, U:1:354093:914739, [U:1:4533645:093919] and [U:1:17309919].

    • Marked as answer by Lersubem Sunday, May 26, 2019 6:08 AM
    Sunday, May 26, 2019 5:59 AM
  • Thank you so much...

    It works.


    • Edited by Lersubem Sunday, May 26, 2019 6:09 AM
    Sunday, May 26, 2019 6:09 AM