Help with regexp macro

radoslaw

Client
Регистрация
11.02.2011
Сообщения
12
Благодарностей
0
Баллы
0
Hi,

I want to parse DomText with a regular expression. Here's my code:

Document doc = tb.MainDocument;
string DomText = doc.GetDomText(false);
string result = instance.RiseMacros("RegExp.RegExp", new [] {DomText, "META", "all"});

The problem is whatever I enter in the second parameter ("META" in my case) the result is this string: "{-RegExp.RegExp".

I tried testing the macro by entering some string instead of the DomText variable.

string result = instance.RiseMacros("RegExp.RegExp", new [] {"META 1234", "META", "all"});

and it properly runs the macro (the result is "META").

What is wrong? Is this some bug?
 

shade

Client
Регистрация
19.11.2010
Сообщения
580
Благодарностей
346
Баллы
63
Hi,
Unfortunately it happens.
Perhaps that DomText contains "-}" or "-|-". So this macro will not help you.
But your problem can be solved by functions of .Net.
 

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Can you give us an example of how to do this Shade? This is critical for doing stuff like scraping google suggest and I'm getting an error that says "Macro doesn't have this macros....."
 

shade

Client
Регистрация
19.11.2010
Сообщения
580
Благодарностей
346
Баллы
63
Can you give us an example of how to do this Shade? This is critical for doing stuff like scraping google suggest and I'm getting an error that says "Macro doesn't have this macros....."
I think it will be better use Regex class from System.Text.RegularExpressions;
JavaScript:
...
...
using System.Text.RegularExpressions;
...
...
// this is input string
string input = "I love ZP. I love ZP :)";
// this is regular expression
string regular_expression = @"ZP";
// create a new Regex object for regular expression
Regex rgx = new Regex(regular_expression, RegexOptions.IgnoreCase);
// collection of all matches
MatchCollection all = rgx.Matches(input);
            
var str = String.Empty;
foreach (Match m in all) str += m.Value + " in position: " + (m.Index+1).ToString() + " ";
will be useful: link
And my example:

 

Вложения

  • Спасибо
Реакции: bigcajones

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)