quran-meta
    Preparing search index...

    Function ayahStringSplitter

    • Splits a string representation of Quran reference into surah and ayah components

      Parameters

      • str: string

        The string to parse, expected format: "surah:ayah" or "surah:ayahStart-ayahEnd"

      • isStrict: boolean = true

        If true, enforces strict format checking. Defaults to true. If false, allows for additional characters in the string

      Returns SurahAyahSegment

      A tuple containing surah number and either a single ayah number or a range [start, end]

      Error If the string format is invalid

      Error If surah number is invalid

      Error If ayah number(s) are invalid

      sError If ayah range is invalid (start should be less than end)

      ayahStringSplitter("2:255") // returns [2, 255]
      ayahStringSplitter("1:1-7") // returns [1, [1, 7]]