The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 895 - File: showthread.php PHP 7.2.34 (Linux)
File Line Function
/showthread.php 895 errorHandler->error




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
beginner: regex ini-like file and variable within regex
#1
Hello,

beginner needing help:

1)
What is the best way to retrieve everthing beneath "[config2]" until the next [...], I want to retrieve "cde" , "fgh" and "ijk"

[config1]
abc

[config2]
cde
fgh
ijk


[config3]
etc...


2)
How can I put a variable within a findrx regex pattern:
Code:
Copy      Help
findrx(lines "^\[config2](?:\r?\n(?:[^[\r\n].*)?)*" 0 8 x)

I want the string "config2" be replaced by a variable for exmple "var_config"
findrx(lines "^\[var_config](?:\r?\n(?:[^[\r\n].*)?)*" 0 8 x)
I tried {var_config}

I tried:
RunTextAsFunction2

But I keep against the double quotes problem
Code:
Copy      Help
str result="findrx(lines "^\[config2](?:\r?\n(?:[^[\r\n].*)?)*" 0 8 x)"

I also tried to replace the inner pair of double quotes with double single quotes like this: '' ... regex...''

thanks!


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)