en:instrx [BASIC 256 - Language Documentation]

# BASIC 256 - Language Documentation

en:instrx

## Instrx (Function)

### Format

instrx ( haystack_expr , regex_expr )
instrx ( haystack_expr , regex_expr , start_expr )

returns positive_integer_expr

### Description

Check to see if the text represented by the regular expression regex_expr is contained in the string haystack_expr. If it is, then this function will return the index of starting character of the first place where needle_expr occurs. Otherwise, this function will return 0. You may also specify an optional starting location for the search to begin start_expr. Unlike INSTR, INSTRX allows ignoring specific variations (case sentive, spelling etc).

### Note

String indices begin at 1.

### Example

    print instrx("HeLLo", "[Ll]o")
    print instrx("Hello, Kitti","[Ii]",10)

will display

    4
    12

### Notes

instrx can be used to test if a string matches a regular expression. In for following example the function isnumber returns true if the string passed is in for format of a floating point number and false if not.

    function isnumber(s$)
       # return true if a number - false of not
       return instrx(s$,"^-?\d+\.?\d*$") <> 0
    end function

By default the nature of regular expressions is “greedy”. This behaviour can be changed using the RegexMinimal statement.

### See Also

Asc, Chr, Count, Countx, Explode, Explodex, Implode, Instr, Instrx, Left, Length, Lower, MD5, Mid, Midx, Replace, Replacex, Right, String, Upper

### History

0.9.6.56 | New To Version

en/instrx.txt · Last modified: 2014/08/06 20:18 by admin