Hello,
I am having a hard time using the match proc to catch occurences of a regular expression in a string. It is the same regex I use in Perl, but it does not seem to match here:
import parseutils
import strutils
import re
import pcre
import unicode
type TMatches = array[0..1, string]
var matches: TMatches
var currentline = "some <bold<text> and <italic<text>. Also some <cmd 1, cmd 2, cmd 3<text>."
var regex: TRegex = re"<.*?<"
if match(currentline,regex,matches):
echo(matches[0])
echo(matches[1])
else:
echo "No matches"
Anyone who could point out where I am going wrong would be appreciated.
Thanks!
import re type Matches = array[0..1, string] var matches: Matches let currentline = "Hallo <Stefan>" let regex = re"(Hallo)\s(<\w*>)" if match(currentline,regex,matches): echo(matches[0]) echo(matches[1]) else: echo "No matches"
Output for bigbreak is as exspected: Hallo <Stefan>
Currently I have no idea what is wrong with your example, maybe I can do more testing this evening. (I have only experience with Ruby pattern matching, Nim libraries may work not exactly the same...)