User Tools

Site Tools


en:instrx

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:instrx [2016/08/13 08:59]
admin
en:instrx [2020/02/28 10:46]
Line 1: Line 1:
-===== Instrx (Function) ===== 
-==== Format ==== 
-**instrx** ( [[stringexpressions|haystack_string_expression]] , [[regularexpressions|regular_expression]] )\\ 
-**instrx** ( [[stringexpressions|haystack_string_expression]] , [[regularexpressions|regular_expression]] , [[integerexpressions|start_expression]] ) 
- 
-returns [[integerexpressions|integer_expression]] 
- 
-==== Description ==== 
-Check to see if the text represented by the regular expression [[regularexpressions|regular_expression]] is contained in the string [[stringexpressions|haystack_string_expression]].  If it is, then this function will return the index of starting character of the first place where [[stringexpressions|needle_string_expression]] occurs.  Otherwise, this function will return 0. 
- 
-You may optionally specify a starting location for the search to begin [[integerexpressions|start_expression]].  If the start is 1 or greater the search will begin from the specified character from the start.  If the start is < 0 then the search will begin from the nth character from the end.  The search will ALWAYS look forward. 
- 
-==== Note ==== 
-String indices begin at 1. 
- 
-==== Example ==== 
-<code> 
-print instrx("HeLLo", "[Ll]o") 
-print instrx("Hello, Kitti","[Ii]",10) 
-</code> 
-will display 
-<code> 
-4 
-12 
-</code> 
- 
-==== 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.  
-<code> 
-function isnumber(s$) 
-   # return true if a number - false of not 
-   return instrx(s$,"^-?\d+\.?\d*$") <> 0 
-end function 
-</code> 
- 
-By default the nature of regular expressions is "greedy". This behaviour can be changed using the [[regexminimal|RegexMinimal]] statement. 
- 
-==== See Also ==== 
-{{page>en:start#String Handling&noheader}} 
- 
-==== History ====  
-|0.9.6.56|New To Version| 
-|1.99.99.53|Added start position < 0| 
  
en/instrx.txt ยท Last modified: 2020/02/28 10:46 (external edit)