Loading String value using ParseConfig from Parse.com with new line character - string

i have a problem to load a String value using ParseConfig from Parse.com with new line character.
The new line character is ignored, is that normal or i'm doing something wrong?
There is any other solution to get a text with new line character without using html code and uiwebview?

This question is old, but I'm posting here for posterity as I had the same issue.
On Parse, use another character such as <br> where you want a new line in your String.
Then, in Swift or Objective C, replace <br> with \n, which is recognized by Swift:
Swift:
// Assume you've loaded a String from Parse, called 'rawStringFromServer'
let newString = rawStringFromServer.replacingOccurrences(of: "<br>", with: "\n")
myUILabel.text = newString

Related

extendscript replace string if this file path not working

how do I replace this string it seems like all words join up rather than replacing the string.
the output does not seem to replace
var str='C:\Program Files\Adobe\Adobe After Effects 2022\Support Files\Presets';
str.replace("\\", "\\\\");
alert (str);

How to remove a sub string pattern from a json string in vim?

json_str = {"type":"0","num":"1","processtime_ms":"14","model":"label"}
I have a lot of json string like this, and I want to remove this part from the string in vim:
"processtime_ms":"14",
I know how to remove a full line when matching a pattern, but how to remove the substring?
:1,$s/"processtime_ms":"14",//g
will remove the pattern from every line in the file

How can I do line breaks in a formatted string string python3

simple question that I hope has a simple answer
I want to store a formatted string to pass later to function call. I would like to have line breaks baked into one long string rather than send a string for each line. So for example
b = f'hello \n world'
b
this gives me 'hello \n world' which is not what I want.
How can I do this in a compact manner. I would prefer to avoid joins or something like that with a newline separator.
Thanks in advance.

Reading from a string using sscanf in Matlab

I'm trying to read a string in a specific format
RealSociedad
this is one example of string and what I want to extract is the name of the team.
I've tried something like this,
houseteam = sscanf(str, '%s');
but it does not work, why?
You can use regexprep like you did in your post above to do this for you. Even though your post says to use sscanf and from the comments in your post, you'd like to see this done using regexprep. You would have to do this using two nested regexprep calls, and you can retrieve the team name (i.e. RealSociedad) like so, given that str is in the format that you have provided:
str = 'RealSociedad';
houseteam = regexprep(regexprep(str, '^<a(.*)">', ''), '</a>$', '')
This looks very intimidating, but let's break this up. First, look at this statement:
regexprep(str, '^<a(.*)">', '')
How regexprep works is you specify the string you want to analyze, the pattern you are searching for, then what you want to replace this pattern with. The pattern we are looking for is:
^<a(.*)">
This says you are looking for patterns where the beginning of the string starts with a a<. After this, the (.*)"> is performing a greedy evaluation. This is saying that we want to find the longest sequence of characters until we reach the characters of ">. As such, what the regular expression will match is the following string:
<ahref="/teams/spain/real-sociedad-de-futbol/2028/">
We then replace this with a blank string. As such, the output of the first regexprep call will be this:
RealSociedad</a>
We want to get rid of the </a> string, and so we would make another regexprep call where we look for the </a> at the end of the string, then replace this with the blank string yet again. The pattern you are looking for is thus:
</a>$
The dollar sign ($) symbolizes that this pattern should appear at the end of the string. If we find such a pattern, we will replace it with the blank string. Therefore, what we get in the end is:
RealSociedad
Found a solution. So, %s stops when it finds a space.
str = regexprep(str, '<', ' <');
str = regexprep(str, '>', '> ');
houseteam = sscanf(str, '%*s %s %*s');
This will create a space between my desired string.

Selenium IDE: how to remove \n from stored string?

I am trying to extract the zip code from an address string but it contains newline \n characters. May I ask how to remove it from a selenium stored var? I have tried to use storeEval | "${Addrsss}".replace("\n", "") | Address. But, selenium ide will return the error Threw an exception: unterminated string literal
Here is the address:
${Address} = "100 RILEY DR\n AVONDALE,\n ARIZONA\n 85323-2004"
Try this sequence of escape>replace>unescape as a workaround to remove the new line character:
Escape the value,
Replace the escaped new line character (%0A) with blank (''),
Unescape back to the original value,
storeEval | unescape(escape(storedVars['has_nl']).replace(/%0A/g,'')) | no_nl
This new line character appears to have come from HTML break tag (<br />) that is rendered by the browser-Selenium-IDE combination, then extracted by Selenium IDE as new line character (\\n).
Possible approach:
1) find proper css (or xPath) locator of the element (address)
2) then get contents ( text) from element using
String cssSelecotr=..blablabla..
//1st way
String myAddress=driver.findELement(by.cssSelector(cssSelector)).getText();
//2nd way, using js executor
JavascriptExecutor js = (JavascriptExecutor) driver;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("var x = $(\""+cssSelecotr+"\");");
stringBuilder.append("return x.text().toString();") ;
String myAddress= (String) js.executeScript(stringBuilder.toString());
3) then you can apply regExp ( all visible symbols) for yourAdress
// myAddress ="100 RILEY DR\n AVONDALE,\n ARIZONA\n 85323-2004";
String myAdressEdited = myAddress.replaceAll("[^\\x20-\\x7E]+","");
Hope this helps

Resources