pear2/Net_RouterOS — Issue #5: Trying to send a REGEXP
Author: CristianDeluxe
Created: 2011-11-17 10:24:56+00:00
State: open

Hi, i need to send a command with REGEXP to my ROS and i'm using your API helper.

This is the command:
``` /ip dhcp-server lease print count-only where active-address~"1.1.1." ```

I've modified the Query file:

```php
getTransmitter()->isAcceptingData()) {
throw new SocketException(
'Transmitter is invalid. Sending aborted.', 209
);
}
$bytes = 0;
foreach ($this->words as $queryWord) {
list($predicate, $value) = $queryWord;
$prefix = '?' . $predicate;
if (null === $value) {
$bytes += $com->sendWord($prefix);
} else {
+	if(substr($predicate, 0, 1) === '~') {
+	$prefix = '?' . str_replace('~', '', $predicate) . '~';
+	} else {
+	$prefix .= '=';
+	}
if (is_string($value)) {
$bytes += $com->sendWord($prefix . $value);
} else {
$bytes += $com->sendWordFromStream($prefix, $value);
}
}
}
return $bytes;
}
?>
```

This is my test script:

```php
setArgument('count-only', '');
$query = Query::where('active-address', '"10.80."', '~');
$request->setQuery($query);

$responses = $client->sendSync($request);

foreach ($responses as $response) {
foreach ($response->getAllArguments() as $name => $value) {
echo "{$name}: {$value}\n";
}
echo "====\n";
}

echo 'END'. "\n\n\n";
?>
```

I've modified the "sendWord" function inside "Communicator.php" file, adding a

```php

```
for debugging purposes and this is the result:

```

sending word: /login

sending word:

sending word: /login

sending word: =name=myuser

sending word: =response=myencriptedpassword

sending word:

sending word: /ip/dhcp-server/lease/print

sending word: =count-only=

sending word: ?active-address~"10.80."

sending word:
ret: 0
====
FIN

```

How can I make this work? thanks for the hard work with your API helper : )