Regular expressions: Difference between revisions

Content added Content deleted
(Added PureBasic)
Line 496: Line 496:
"I am a string" -replace 'a\b','no' # I am no string</lang>
"I am a string" -replace 'a\b','no' # I am no string</lang>
By default both the <code>-match</code> and <code>-replace</code> operators are case-insensitive. They can be made case-sensitive by using the <code>-cmatch</code> and <code>-creplace</code> operators.
By default both the <code>-match</code> and <code>-replace</code> operators are case-insensitive. They can be made case-sensitive by using the <code>-cmatch</code> and <code>-creplace</code> operators.

=={{header|PureBasic}}==
<lang PureBasic>String$ = "<tag>some text consisting of Roman letters spaces and numbers like 12</tag>"
regex$ = "<([a-z]*)>[a-z,A-Z,0-9, ]*</\1>"
regex_replace$ = "letters[a-z,A-Z,0-9, ]*numbers[a-z,A-Z,0-9, ]*"
If CreateRegularExpression(1, regex$) And CreateRegularExpression(2, regex_replace$)
If MatchRegularExpression(1, String$)
Debug "Tags correct, and only alphanummeric or space characters between them"
EndIf
Debug ReplaceRegularExpression(2, String$, "char stuff")
EndIf</lang>


=={{header|Python}}==
=={{header|Python}}==