Answer the question
In order to leave comments, you need to log in
What is the correct way to express yourself regularly?
Hello, I am writing a preprocessor for PHP, I need help.
I don’t know why, but I can’t select the necessary parts of the code, the problem is the line break, although the documentation says that .(dot) is any character.
Here at the moment everything is somehow like this
Task:
It is necessary that he also perceive the line break characters.
Here is the pattern
#<\?(.+)\?>#
Here is the text
<?php
$class=get_class($model);
Yii::app()->clientScript->registerScript('gii.crud',"
$('#{$class}_controller').change(function(){
$(this).data('changed',$(this).val()!='');
});
$('#{$class}_model').bind('keyup change', function(){
var controller=$('#{$class}_controller');
if(!controller.data('changed')) {
var id=new String($(this).val().match(/\\w*$/));
if(id.length>0)
id=id.substring(0,1).toLowerCase()+id.substring(1);
controller.val(id);
}
});
");
?>
<h1>Crud Generator</h1>
<p>This generator generates a controller and views that implement CRUD operations for the specified data model.</p>
<?php $form=$this->beginWidget('CCodeForm', array('model'=>$model)); ?>
<div class="row">
<?php echo $form->labelEx($model,'model'); ?>
<?php echo $form->textField($model,'model',array('size'=>65)); ?>
<div class="tooltip">
Model class is case-sensitive. It can be either a class name (e.g. <code>Post</code>)
or the path alias of the class file (e.g. <code>application.models.Post</code>).
Note that if the former, the class must be auto-loadable.
</div>
<?php echo $form->error($model,'model'); ?>
</div>
Answer the question
In order to leave comments, you need to log in
Add the s modifier (consider all text as one line) and turn off the "greedy" modifier "+" (note the question mark after the "+"):
#<\?(.+?)\?>#s
If I understood you correctly, then this is how it turned out #<\?(.+?)\?>#s 5 matches are obtained
But all the same, it’s better to do it with something else and not with a regexp
The simplest version and do not care about multiline with the s modifier:
#<\?([\x00-\xFF]+)\?>#
I don't know anything about regular expressions in php, but isn't there an end-of-line character? In python, perl, _a bunch of other names_ - this is "$"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question