Preg_replace pattern with brackets and quotes - preg-replace

How to transform this :
My text
Into this :
My text
I've tried this :
$masque1 = "/\{cms_selflink href=\'(.*?)\'(.*)\}/i";
$masque2 = '/page/$1';
$texte = preg_replace($masque1, $masque2, $texte);
But this don't work.
Any idea plz ? Thx

This work :
$masque1 = "/\{cms_selflink href=\'(.+?)\' \}/s";

Related

Replace backSlash '\' with a normal slash '/' in dart

Hi guys I have an imageUrl with backSlashes('\\') I want to replaceAll the backSlashes with a normal slash ('/')
this is an imageUrl example :
public\images\providerProfilePictures\2022-04-04T19-08-50.943Z-scaled_image_picker8914175492511161913.jpg
I want to make it with normal slashes like this one :
public/images/providerProfilePictures/2022-04-04T19-08-50.943Z-scaled_image_picker8914175492511161913.jpg
this is my code :
path = decoded['profilePictureUrl'];
if (path!=''){
path.replaceAll('/', '\\');
path=ApiConstants.BASE_URL+path;
print(" my path now : "+path);
I'm getting a wrong result with this function any help would be appreciated
I think you got the 2 parameters swapped.
You have:
path.replaceAll('/', '\\');
It should be:
path.replaceAll('\\', '/');
Unrelated, but instead of if (path!='') you could write if (path.isNotEmpty) for improved readability.
Also, you can use the letter r in front of a String to make it verbatim.
Try this:
final s = r'public\images\providerProfilePictures\2022-04-04T19-08-50.943Z-scaled_image_picker8914175492511161913.jpg';
final url = s.replaceAll('\\', '/');
print(url);
Console output:
flutter:
public/images/providerProfilePictures/2022-04-04T19-08-50.943Z-scaled_image_picker8914175492511161913.jpg

Flutter get first word

I'm trying to get the first word but I can't seem to find a way. I've tried using split like so:
Text("${contactList[index].userName!.split(" ")}, ")
But the result is an array like so:
[aufa, taf]
Any solutions?
according to the results you should write:
Text("${contactList[index].userName!.split(" ")[0]}, ")
instead of :
Text("${contactList[index].userName!.split(" ")}, ")
Try below code hope its help to you.
Text("${contactList[index].userName!.split(" ").elementAt(0)"),
Simple Example:
void main() {
String sampleText = "aufa taf";
var first = sampleText.split(" ").elementAt(0); // aufa
var second = sampleText.split(" ").elementAt(1);//taf
print(first);
}
Try this:
Text(
"${contactList[index].userName!.split(" ")[0]}, ",
),

TYPO3/Typoscript : trim value failed

This is my typoscript code :
lib.test.renderObj = COA
lib.test.renderObj.10 = TEXT
lib.test.renderObj.10.stdWrap.field = header
lib.test.renderObj.10.stdWrap.case = lower
lib.test.renderObj.10.stdWrap.trim = 1
lib.test.renderObj.10.stdWrap.wrap = <div class="element">|</div>
The header field is well received, letters have been lowercased and the field is well wrapped by a element. The only problem is that i can't make the TRIM properties effective. I also tried to use the search/replace properties -> no success.
Any clue ? :)
You can search and replace since 4.6. The documentation you can find here: https://docs.typo3.org/typo3cms/TyposcriptReference/6.2/Functions/Replacement/
lib.test.renderObj.10.stdWrap.replacement {
10 {
search = # #
replace =
useRegExp = 1
}
}
Don't know if the replace is really working, can't test it.

How to use a condition in a static text field?

I'm using condition to print field values.My condition is if isList == "list" then print value of region_name.Following codes works fine.
<textFieldExpression><![CDATA[($F{isList} == "list" ? "" : $F{region_name})]]></textFieldExpression>
But now I need to print static text using condition too. When I'am using same method,it doesn't work.It shows "($F" instead of static text.
<text><![CDATA[($F{isList} == "list" ? "Region:" : "")]]></text>
What is wrong ? How I can fix it ?

Regular expression in Smartface

how can I use regex in Smartface for editboxes' text area?
Can someone give an example?
Should I write the expression to the text area directly or it must be done another way?
I don't know what kind of regular expression you need.
A simple usage will be as below :
var price = '$55.99';
var priceRegex = /[(0-9)+.?(0-9)*]+/igm;
var price2 = parseFloat(priceRegex.exec(price));
var myEditbox1 = new SMF.UI.EditBox({
text : price,
top : "20%"
});
var myEditbox2 = new SMF.UI.EditBox({
text : price2,
top : "50%"
});
I used a priceRegex as a regular expression in script file.
You can add these two editbox objects to your page in order to see the result.