0
p = "<a href=\".*?\"\\stitle=\"(.*?\")>.*?<\/a><span class=\"event-nodetype\">\((.*?\)</span><span class=\"event-timeleft\">\()(.*?\)<\/span><li>)";

This is regex i created for

<a href="/bu/?q=node/775" title="YOK ED?LEN MEDEN?YET: GEÇ OSMANLI VE ERKEN CUMHUR?YET DÖNEMLER?NDE GAYR?MÜSL?M VARLI?I">YOK ED?LEN MEDEN?YET: GEÇ OSMANLI VE ERKEN CUMHUR?YET DÖNEMLER?NDE GAYR?MÜSL?M VARLI?I</a><span class="event-nodetype">(Konferans / Kongre / Sempozyum)</span><span class="event-timeleft">(Devam etmekte)</span><li> 

But eclipse gives error of

Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )

I put \ to " and other things but still i cant fix it.

What is the problem?

When i split the line into 4 lines

 p = "<a href=\".*?\"\\stitle=\"(.*?\")>"
        + ".*?<\/a><span class=\"event-nodetype\">\(("
        + ".*?\)</span><span class=\"event-timeleft\">\()("
        + ".*?\)<\/span><li>)";

the error seems on line 2.

7
  • There's an invalid escape sequence towards the end of the line: <\/span> Commented Nov 20, 2015 at 17:54
  • but in html </span><li> i need to put that so i need that slash?and it did not change anything. Error seems at beginning because beginning of this line is red Commented Nov 20, 2015 at 17:55
  • It all depends in the language that you are using. The error message doesn't list a forward slash as one of the escaped sequences, so it's probably safe to say that you don't need to escape it here. Commented Nov 20, 2015 at 17:57
  • There is also this one on the second line of your edit: <\/a> Commented Nov 20, 2015 at 18:00
  • I did but this time eclipse doesnot give what i want. But according to regexr.com, i could find 6 matches. Now none. Commented Nov 20, 2015 at 18:17

1 Answer 1

1

\" is correct, an so is \\s (but I would use \\s+). All the other backslashes in your regex need to be escaped: \\/, \\(, \\) (/ doesn't need escaping, but doing so doesn't hurt anything). This is for the string literal, not for the regex; the backslash is an escape character for both.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.