Author Topic: Find first instance of ';' or '{'  (Read 839 times)

flethuseo

  • Senior Community Member
  • Posts: 173
  • Hero Points: 2
Find first instance of ';' or '{'
« on: November 01, 2016, 07:59:39 pm »
This piece of code works good to find the end of a statement. I'm wondering if it can be changed to search for the first instance of either ';' or '{'. Any good way to do that:
// Find end of statement. This handles multiple-line statements.
   search(";","@hXcs");

flethuseo

  • Senior Community Member
  • Posts: 173
  • Hero Points: 2
Re: Find first instance of ';' or '{'
« Reply #1 on: November 01, 2016, 10:21:44 pm »
Hmm I think I've figured this one out myself:
   
Code: [Select]
if (search("[;|{]","+>R?")) stop();
I did want to ask though, how do I escape a quote string on regular search expressions with slickedit reg expressions. I have tried '" and \" and neither worked.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4035
  • Hero Points: 269
Re: Find first instance of ';' or '{'
« Reply #2 on: November 04, 2016, 11:30:49 am »
Hmm I think I've figured this one out myself:
   
Code: [Select]
if (search("[;|{]","+>R?")) stop();
I did want to ask though, how do I escape a quote string on regular search expressions with slickedit reg expressions. I have tried '" and \" and neither worked.
It's better to use single quoted strings for regular expressions.

Double quoted regex search for backslash: "\\\\"
Single quoted regex search for backslash: '\\'