Great one, thanks!
Re shorter way, it can be written as a one-liner:
result = matchall(Regex("^$(var)+"), mystring)
marți, 17 martie 2015, 23:49:57 UTC+1, David P. Sanders a scris:
>
>
>
> El martes, 17 de marzo de 2015, 15:14:35 (UTC-6), Julia User escribió:
>>
>> How to use a julia variable in a regex string (interpolate).
>>
>> var = " "
>> reg = r"^$(var)+" # Something like this
>> result = matchall(reg, mystring)
>>
>>
>> Is there a way to make this work?
>>
>
> How about the following? I don't know if there's a shorter way.
>
>
> var = " "
> reg_string = "^$(var)+" # standard Julia string
> reg = Regex(reg_string) # make a regular expression out of the string
> result = matchall(reg, mystring)
>
>
>
> Best,
> David.
>
>
>
>>
>> Thanks
>>
>>
>>
>>