Rythm is changing my mailId <name>#gmail.com as it contains "#" - rythm

I am using Rythm to modify multiple strings in my main String Object. Issue is my main String Object contains mail Id also. As I don't want to replace #gmail.com, I have not declared it in the Template. But Rythm is trying to modify that also.
So if I declare my string as "abc#gmail.com" I am getting the below exception.
Exception in thread "main" org.rythmengine.exception.CompileException: gmail.com cannot be resolved to a type
Template: 0 PIN_FLD_EMAIL_ID STR [0] "abc#gmail.com"
Relevant template source lines:
1: 0 PIN_FLD_EMAIL_ID STR [0] "abc#gmail.com"
Relevant Java source lines:
#Override public org.rythmengine.utils.TextBuilder build(){
buffer().ensureCapacity(49);
p("0 PIN_FLD_EMAIL_ID STR [0] \"abc"); //line: 1
try{pe(gmail.com);} catch (RuntimeException e) {__handleTemplateExecutionException(e);} //line: 1
p("\""); //line: 1
return this;
}
}
If I put it like abcgmail.com then it is able to accept it, but I need # also. Is there is anyway that my String contains "#" and Rythm may keep it as it is ??
Regards
Yogesh Joshi

use two ## to escape, so your string should contain abc##gmail.com instead of abc#gmail.com. See more on http://rythmengine.org/doc/template_guide.md#at

Related

How to insert a placeholder in a json key:value ? Flutter

I'm porting my Swift app to Flutter and for localising it I'm following this https://github.com/billylev/flutter_localizations but I can't see how to insert placeholder to insert a value in the translated values.
Basically the guide uses
String text(String key) {
return _localisedValues[key] ?? "$key not found";
}
to get the corresponding key:value pair from a .json file as
{
"Shop": "Negozio",
}
I just pass it in the Textwidget as :
Text(AppLocalizations.instance.text('Shop')).
How to modify text to insert one or more placeholders and how would be the .json be constructed?
Say for the value "User": "User" I'd like to insert a value after the transaction I can simply use a string sum and add the value as `Text(
AppLocalizations.instance.text('User') + ' ${widget.user.name}', but if I need to insert a value in the middle of the translated sentence, eg a message, I don't see how to accomplish it.
I need it to make localised versions of incoming push notification, and they have args.
In Swift I have it like this:
"ORDER_RECEIVED_PUSH_TITLE" = "Order number: %#";
"ORDER_RECEIVED_PUSH_SUBTITLE" = "Shop: %#";
"ORDER_RECEIVED_PUSH_BODY" = "Thank you %#! We received your order and we'll let you know when we start preparing it and when it's ready. Bye";
Any suggestions on how to accomplish that in Flutter?
Many thanks
I was suggested this package https://pub.dev/packages/sprintf#-installing-tab- and it works just as I needed. Sprintf just lets you specify one or more placeholders in a String and pass an array of args.
https://developermemos.com/posts/using-sprintf-flutter-dart. for more info, even this is pretty much it. So for example
"ORDER_RECEIVED_PUSH_TITLE" = "Order number: %#";
in the .json file would be :
{
"ORDER_RECEIVED_PUSH_TITLE": "Oder number: %s"
}
and using it would be
String orderNumber = 'some uuid';
Text(Sprintf(AppLocalitazions.instance.text('ORDER_RECEIVED_PUSH_TITLE'),[orderNumber]);
Hope this helps others.

How to cut a string from the end in UIPATH

I have this string: "C:\Procesos\rrhh\CorteDocumentos\Cortados\10001662-1_20060301_29_1_20190301.pdf" and im trying to get this part : "20190301". The problem is the lenght is not always the same. It would be:
"9001662-1_20060301_4_1_20190301".
I've tried this: item.ToString.Substring(66,8), but it doesn't work sometimes.
What can I do?.
This is a code example of what I said in my comment.
Sub Main()
Dim strFileName As String = ""
Dim di As New DirectoryInfo("C:\Users\Maniac\Desktop\test")
Dim aryFi As FileInfo() = di.GetFiles("*.pdf")
Dim fi As FileInfo
For Each fi In aryFi
Dim arrname() As String
arrname = Split(Path.GetFileNameWithoutExtension(fi.Name), "_")
strFileName = arrname(arrname.Count - 1)
Console.WriteLine(strFileName)
Next
End Sub
You could achieve this using a simple regular expressions, which has the added benefit of including pattern validation.
If you need to get exactly eight numbers from the end of file name (and after an underscore), you can use this pattern:
_(\d{8})\.pdf
And then this VB.NET line:
Regex.Match(fileName, "_(\d{8})\.pdf").Groups(1).Value
It's important to mention that Regex is by default case sensitive, so to prevent from being in a situations where "pdf" is matched and "PDF" is not, the patter can be adjusted like this:
(?i)_(\d{8})\.pdf
You can than use it directly in any expression window:
PS: You should also ensure that System.Text.RegularExpressions reference is in the Imports:
You can achieve it by this way as well :)
Path.GetFileNameWithoutExtension(Str1).Split("_"c).Last
Path.GetFileNameWithoutExtension
Returns the file name of the specified path string without the extension.
so with your String it will return to you - 10001662-1_20060301_29_1_20190301
then Split above String i.e. 10001662-1_20060301_29_1_20190301 based on _ and will return an array of string.
Last
It will return you the last element of an array returned by Split..
Regards..!!
AKsh

New Line Command (\n) Not Working With Firebase Firestore Database Strings

I'm making an app with Swift and I'm using Firebase Firestore. Firestore is a database that has some strings that I put into a UILabel. With some of my strings, I am using the new line command (or \n). So some of my strings look like this:
"This is line one\nThis is line two\nThis is line three"
But, whenever that string is retrieved, it's addetoto the UILabel and appears like this...
This is line one\nThis is line two\nThis is line three
...when it should be like this...
This is line one
This is line two
This is line three
I'm assuming that \n does not work with strings coming from a database? I've tried double escaping with \\n. Does anyone have a fix for this?
Here is the code that I am using...
database.collection("songs").whereField("storyTitle", isEqualTo: "This is the story header").getDocuments { (snapshot, error) in
for document in (snapshot?.documents)! {
self.storyBodyLabel.text = (document.data()["storyBody"] as? String)!
}
}
I got it. I simply just replaced the character "\n" from the string that I was receiving with the newline command.
label.text = stringRecived.replacingOccurrences(of: "\n", with: "\n")
Because I manually typed out my string and gave Firebase a string like
"Line one\nline two\nline three" I am replacing "\n" with "\n" But if you give Firebase a string like
"Line one
Line two
Line three"
Firebase replaces those returns with "\\n" therfore making the code
label.text = stringRecived.replacingOccurrences(of: "\\n", with: "\n")
Hope that helps!
You can use CSS whitespace property for \n, it works for me.
white-space: pre-line;
Solution: Add this to your string and you are done (for Java users):
.replace("\\n", "\n")
Example:
if (dataSnapshot.exists())
{
ArrayList<String> userlogs2 = new ArrayList<String>();
userlogs2.add(dataSnapshot.getValue().toString().replace("\\n", "\n"));
Iterator<String> it2 = userlogs2.iterator();
while (it2.hasNext()) {
appendColoredText(userlogsmessages2, it2.next() + "\n", Color.BLACK);
appendUnderlinedText(userlogsmessages2,"____________" + "\n\n", Color.parseColor("#DB808080"));
}
Firestore doesn't support any escape sequences within string values. If you write "\n" in a string, you're going to get exactly that back when you read it. If you need to store something special, you may want to encode and decode that yourself.
Tried all of the answers suggested but none worked for me. In the end, I fixed it by using "/n" in the Firestore record and, in the Swift client, the following:
label.text = stringReceived.replacingOccurrences(of: "/n", with: "\n")
For me firebase turned all \n to \\\\n , so I just reversed that change with :
theString.replaceAll( "\\\\n", "\n" );
Just posting cause I wasted some time calculating the right number of '\'
I found I could get newlines into a firestore field by using the String.fromCharCode() function. Firestore seems to need special characters in strings to be the actual character ASCII values and does not reinterpret escape characters.
i.e.
"First Line " + String.fromCharCode(13) + "second line"
100% Working
DB.collection(Global.DB_COLLECTION_PATH).document(NEWS_ID).get().addOnCompleteListener(new OnCompleteListener< DocumentSnapshot >() {
#Override
public void onComplete(#NonNull Task< DocumentSnapshot > task) {
if (task.isSuccessful()) {
body1 = task.getResult().getString("newsBody").replace("\n", "\n");
nBody.setText(body1);
}
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Log.e("DB FAILED", e.getMessage());
}
});
I hope it's work for you
I noticed that when you add a string with \n to the JSON export and then upload the JSON to the Realtime Database, it acts as a newline. But if you edit that from the firebase console, it gives you back the string with \n and not a newline.
Firestore add this type----Line one\nline two\nline three
get Sting, replace and show with TextView
String sura=modellist.get(position).getSura().replace( "\n", "\n");
Working..

Search removing comma using Entity Framework

I want to search a text that contains comma in database, but, there is not comma in the reference.
For example. In database I have the following value:
"Development of computer programs, including electronic games"
So, I try to search the data using the following string as reference:
"development of computer programs including electronic games"
NOTE that the only difference is that in database I have a comma in the text, but, in my reference for search, I have not.
Here is my code:
public async Task<ActionResult>Index(string nomeServico)
{
using (MyDB db = new MyDB())
{
// 1st We receive the following string:"development-of-computer-programs-including-electronic-games"
// but we remove all "-" characters
string serNome = nomeServico.RemoveCaractere("-", " ");
// we search the service that contains (in the SerName field) the value equal to the parameter of the Action.
Servicos servico = db.Servicos.FirstOrDefault(c => c.SerNome.ToLower().Equals(serNome, StringComparison.OrdinalIgnoreCase));
}
}
The problem is that, in the database, the data contains comma, and in the search value, don't.
In you code you are replacing "-" with "" and that too in your search string. But as per your requirement you need to change "," with "" for your DB entry.
Try doing something like this:
string serNome = nomeServico.ToLower();
Servicos servico = db.Servicos.FirstOrDefault(c => c.SerNome.Replace(",","").ToLower() == serNome);

how to maintain the spaces between the characters?

i am using the following code
String keyword=request.getParameter("keyword");
keyword = keyword.toLowerCase();
keyword.replaceAll(" "," "); //first double space and then single space
keyword = keyword.trim();
System.out.println(keyword);
i am given the input as t s
but iam getting as
[3/12/10 12:07:10:431 IST] 0000002c SystemOut O t s // here i am getting the two spaces
how can decrease two single space
use the follwoing program
public class whitespaces {
public static void main(String []args){
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
System.out.println( str.replaceAll("\b\s{2,}\b", " "));
}catch(Exception e){
e.printStackTrace();
}
}
}
thanks,
murali
If your database always have only one space, you could use some keypress event to automatically ignore any occurrences of multiple spaces (by replace double spaces with single space in the search string or something).
StackOverflow has solved the same (or at least a similar) problem regarding spaces in tags, by not having them. Instead, if you want to denote a space in a tag on SO, use - (dash). You could run a query to replace all spaces with - in your database (even though it would probably take quite some time to run you'll only have to do it once). If you want to display them as spaces on the page, just do a replace when you render.