Title: Problem with line of code
Last modified: August 30, 2016

---

# Problem with line of code

 *  Resolved [Conal Mullan](https://wordpress.org/support/users/conalmullan/)
 * (@conalmullan)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/problem-with-line-of-code/)
 * I am trying to use this code within [insert_php] but it keeps breaking everything,
   i.e. the code doesnt get interpreted into php and is just rendered as is on the
   webpage.
 * I have had a look around and cant figure out what is causing it to break.
    Any
   help would be great.
 * `function isDomain($domain1) {if (preg_match("{^.+\.[a-z]{2,}\$}", $domain1)){
   return true; } return false; }`
 * Thanks.
 * [https://wordpress.org/plugins/insert-php/](https://wordpress.org/plugins/insert-php/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/problem-with-line-of-code/#post-6337558)
 * ConalMullan, it has to do with the curly braces in preg_match().
 * I don’t know exactly what they do in the eval() function (Insert PHP works by
   putting the code through the eval() function), as I haven’t yet completed my 
   testing.
 * In the meantime, this should work as a work-around:
 *     ```
       [insert_php]
       function isDomain($domain1)
       {
          if (preg_match('/^.+\.[a-z][a-z]+$/', $domain1)) { return true; }
          return false;
       }
       echo isDomain('example.com') ? 'YES' : 'no';
       [/insert_php]
       ```
   
 * Will
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/problem-with-line-of-code/#post-6337560)
 * Sorry, inadvertently ticked the “resolved” box and see no way to un-resolve the
   thread.
 *  Thread Starter [Conal Mullan](https://wordpress.org/support/users/conalmullan/)
 * (@conalmullan)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/problem-with-line-of-code/#post-6337654)
 * Thanks Will – that has worked!
 * I have one more that is doing the same thing but apparently for a different reason?
 * `function isIP($ip1) {return(preg_match('/\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-
   9]?)\.'.'(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.'.'(25[0-5]|2[0-4][0-9]|[01]?[
   0-9][0-9]?)\.'.'(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/',$ip1));}`
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/problem-with-line-of-code/#post-6337656)
 * I looks like you’re finding most of them. I apologize.
 * Yes, the vertical bar character creates havoc in the eval() function. I’ve never
   found a work-around for that. It and other elements that don’t work in Insert
   PHP are talked about here:
    [http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php#nonworkingelements](http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php#nonworkingelements)(
   The curly braces within a regex aren’t listed there, yet. Haven’t finished testing.)
 * Perhaps this can be used to validate the characters of an IP address:
 *     ```
       function ValidateIPaddressFormat($ip)
       {
          $arr = explode('.',$ip);
          if( count($arr) != 4 ) { return false; }
          foreach( $arr as $chunk )
          {
             if( preg_match('/\D/',$chunk) ) { return false; }
             if( $chunk > 255 ) { return false; }
          }
          return true;
       }
       ```
   
 * Will
 *  Thread Starter [Conal Mullan](https://wordpress.org/support/users/conalmullan/)
 * (@conalmullan)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/problem-with-line-of-code/#post-6337658)
 * Thanks Will – all good now.
 * I really appreciate your help with those. I was getting a bit stuck!
 * Conal.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Problem with line of code’ is closed to new replies.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3523853)
 * [Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts](https://wordpress.org/plugins/insert-php/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-php/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-php/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-php/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-php/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-php/reviews/)

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [special-characters](https://wordpress.org/support/topic-tag/special-characters/)

 * 5 replies
 * 2 participants
 * Last reply from: [Conal Mullan](https://wordpress.org/support/users/conalmullan/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/problem-with-line-of-code/#post-6337658)
 * Status: resolved