Variable used inside regex???

sanind

Client
Регистрация
19.11.2011
Сообщения
48
Благодарностей
18
Баллы
8
If i use below macro for regex its working fine


{-RegExp.RegExp-|-{-FieldData.FieldData-|-●6●8●5●2●1●7●-|-≡1≡1≡2≡1≡1≡5≡7≡4≡3≡-}-|-(?<=\<option title\=\"(Health)\" value\=\").*?(?=\"\>)-|-all-}


Now instead of Health i used variable as below and not working

{-RegExp.RegExp-|-{-FieldData.FieldData-|-●6●8●5●2●1●7●-|-≡1≡1≡2≡1≡1≡5≡7≡4≡3≡-}-|-(?<=\<option title\=\"({-FieldData.FieldData-|-●6●2●5●2●4●3●-|-≡4≡2≡4≡6≡0≡6≡7≡8≡9≡-})\" value\=\").*?(?=\"\>)-|-all-}


Execution result of {-FieldData.FieldData-|-●6●2●5●2●4●3●-|-≡4≡2≡4≡6≡0≡6≡7≡8≡9≡-} is Health


Please help .....
 

archel

Client
Регистрация
02.05.2011
Сообщения
175
Благодарностей
22
Баллы
18
What is the original text?
<option title="Health" value="myvalue">
or
<option title="(Health)" value="myvalue">

cause if it is with (), then I think you should add \ in front of them, although I guess it should be without ()
 
  • Спасибо
Реакции: sanind

sanind

Client
Регистрация
19.11.2011
Сообщения
48
Благодарностей
18
Баллы
8
original text <option title="Health" value="myvalue">

regex will work with or without parenthesis... But this is not working only if i substitute variable as i said above
 

sanind

Client
Регистрация
19.11.2011
Сообщения
48
Благодарностей
18
Баллы
8
I found the problem... the Execution result of {-FieldData.FieldData-|-●6●2●5●2●4●3●-|-≡4≡2≡4≡6≡0≡6≡7≡8≡9≡-} has new line character at end...\n or enter character..

Any one can help how to remove this extra space or new line at the end??
 

archel

Client
Регистрация
02.05.2011
Сообщения
175
Благодарностей
22
Баллы
18
If I understand what you mean, then you should use [\w\W]*? instead of .*?
 
  • Спасибо
Реакции: sanind

sanind

Client
Регистрация
19.11.2011
Сообщения
48
Благодарностей
18
Баллы
8
I want to match the entire line, if my search word is found anywhere in the line.

For example, if my search word is "Zenno" it should match the below line(entire line)

I love Zennoposter

For this i am using regular expression *.(?i)Zenno.*

This is working fine but the problem is, it matches the line break(or enter character at end) which is invisible.. Whenever i assigned this matched value to variable its not working because of line break at end.
 

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Have you tried putting \r\n as the look ahead in the regex? There's another way too that I can't remember off the top of my head. I think it's like \s or something like that which will remove the carriage return. Let me know if it doesn't work and I'll see if I can find where I found the answer.
 
  • Спасибо
Реакции: sanind

sanind

Client
Регистрация
19.11.2011
Сообщения
48
Благодарностей
18
Баллы
8
I already tried putting positive look behind but no success

.*(?i)zenno.*(?<=\r) (This matches the expression but still not removing the new line)
.*(?i)zenno.*(?<=\n) ( No match found)

I also tried to use split macro with separator as {-String.Enter-} but not working...

The only solution i found is to save the matched result in temp txt file and taking the line using macro, which strips the new line character but this is not a good solution..

But i know there should be regular expression to remove new line and tried to search in google no luck.. i really appreciate if you can help me. thanks
 

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Did you try \r\n together? If I remember correctly this was the solution. Maybe this will help....

Код:
http://www.regular-expressions.info/charclass.html#shorthand
 
  • Спасибо
Реакции: sanind

sanind

Client
Регистрация
19.11.2011
Сообщения
48
Благодарностей
18
Баллы
8
Thanks all
finally found it.. this below expression at end does the job..thanks

[^\r\n]+
 

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