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

      • data: RiwayaData

      Returns SurahAyahSegment

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

      If the string format is invalid

      If surah number is invalid

      If ayah number(s) are invalid

      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]]