In my Xamarin project I have a Label that formats a Date Value. I updated some Xamarin Nuget packages and now I'm getting the following error:
Strings containing { needs to be escaped. Start the string with
{}"
The Label on the page is a pretty simple StringFormat
<Label Text="{Binding Booking.ScheduledDeparture, StringFormat='{0:dd/MM/yyyy}'}"/>
Any ideas how I can resolve this error. I've tried adding # to the start of the StringFormat but that didn't work.
Add a {} before a string that starts with a { this should escape it. So '{}{0:dd/MM/yyyy}'.
For more documentation: https://learn.microsoft.com/en-us/dotnet/framework/xaml-services/escape-sequence-markup-extension
Related
I have a series of log files in text file format.
The document format is this:
[2021-12-11T10:21:30.370Z] Branch indexing
[2021-12-11T10:21:30.374Z] Starting the program with default pipeID
[2021-12-11T10:21:30.374Z] Running with durable level: max_survivbility will make this program crash if left running for 20 minutes
[2021-12-11T10:21:30.374Z] Starting the program with default pipeID
Each line in the document starts with:[2021-12-11T10:21:30.370Z]
I want to remove the first set of characters that represent date and timestamp and have a result something like this:
Branch indexing
Starting the program with default pipeID
Running with durable level: max_survivbility will make this program crash if left running for 20 minutes
Starting the program with default pipeID
Can anyone please help me explain how I can do this?
I tried to use this method but it doesn't work since I have '[]' in the date stamp.
import re
text = "[2021-12-11T10:21:30.370Z] Branch indexing"
re.sub("[.*?]", "", text)
This doesn't work for me.
If I try the same method on a text like text = "<2021-12-11T10:21:30.370Z> Branch indexing".
import re
text = "<2021-12-11T10:21:30.370Z> Branch indexing"
re.sub("<.*?>", "", text)
It removes <2021-12-11T10:21:30.370Z>. Why does this not work with [2021-12-11T10:21:30.370Z]?
I need help removing every instance of this format "[2021-12-11T10:21:30.370Z]" in all the log files.
Thank you so much.
I'd rather go with a simple solution for this case, pal. Split the string where the ] ends, then trim the second element of the resulting list, to remove all those extra spaces and then print it, bud. Hope this helps, cheers!
import re
text = "[2021-12-11T10:21:30.370Z] Branch indexing"
print(re.split("]", text)[1].strip())
Your current regex pattern is off because square brackets are regex metacharacters which need to be escaped. Also, you should be running the regex in multiline mode. And the timestamp pattern should be more generic.
text = re.sub(r'^\[.*?\]\s+', '', text, flags=re.M)
I'm trying to access a search text box inside of our company's ERP system using Selenium. The screenshot shows the text box and the Xpath of the element.
This is a little tricky, because that Menu Search pop-up isn't really a pop-up. It somehow shows up when a user types Control + M.
By installing ChroPath and testing I've found the text-box always starts with the following string:
txtMenuSearch_Namespace_
I've tried to imitate what's described here, here and here with no luck.
The latest attempt in the snippet of my code looks like this:
menu_search_input_box_elements = driver.find_elements_by_xpath("//*[contains(#id, ‘txtMenuSearch_Namespace_’)]")
for item in menu_search_input_box_elements:
print(item)
I get the following error message:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//*[contains(#id, ‘txtMenuSearch_Namespace_’)]' is not a valid XPath expression.
In all my attempts to get the syntax right I keep getting this message. Any help in figuring out how to .send_keys() to this field is greatly appreciated.
You get en error because of the ‘’ quotes, replace them with correct ones.
# id starts with txtMenuSearch_Namespace_
menu_search_input_box_elements = driver.find_elements_css_selector("[id^='txtMenuSearch_Namespace_']")
menu_search_input_box_elements = driver.find_elements_by_xpath("//*[contains(#id, 'txtMenuSearch_Namespace_')]")
So far I was parsing the NotesCalendarEntry ics manually and overwriting certain properties, and it worked fine. Today i stumbled upon a problem, where a long summary name of the appointment gets split into multiple lines, and my parsing goes wrong, it replaces the part up to the first line break and the old part is still there.
Here's how I do this "parsing":
NotesCalendarEntry calEntry = cal.getEntryByUNID(apptuid);
String iCalE = calEntry.read();
StringBuilder sb = new StringBuilder(iCalE);
int StartIndex = iCalE.indexOf("BEGIN:VEVENT"); // care only about vevent
tmpIndex = sb.indexOf("SUMMARY:") + 8;
LineBreakIndex = sb.indexOf(Character.toString('\n'), tmpIndex);
if(sb.charAt(LineBreakIndex-1) == '\r') // take \r\n into account if exists
LineBreakIndex--;
sb.delete(tmpIndex, LineBreakIndex); // delete old content
sb.insert(tmpIndex, subject); // put my new content
It works when line breaks are where they are supposed to be, but somehow with long summary name, line breaks are put into the summary (not literal \r\n characters, but real line breaks).
I split the iCalE string by \r\n and got this (only a part obviously):
SEQUENCE:6
ATTENDEE;ROLE=CHAIR;PARTSTAT=ACCEPTED;CN="test/Test";RSVP=FALSE:
mailto:test#test.test
ATTENDEE;CUTYPE=ROOM;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED
;CN="Room 2/Test";RSVP=TRUE:mailto:room2#test.test
CLASS:PUBLIC
DESCRIPTION:Test description\n
SUMMARY:Very long name asdjkasjdklsjlasdjlasjljraoisjroiasjroiasjoriasoiruasoiruoai Mee
ting long name
LOCATION:Room 2/Test
ORGANIZER;CN="test/Test":mailto:test#test.test
Each line is one array element from iCalE.split("\\r\\n");. As you can see, the Summary field got split into 2 lines, and a space was added after the line break.
Now I have no idea how to parse this correctly, I thought about finding the index of next : instead of a new line break, and then finding the first line break before that : character, but that wouldn't work if the summary also contained a : after the injected line-break, and also wouldn't work on fields like that ORGANIZER;CN= as it doesn't use : but ;
I tried importing external ical4j jar into my xpage to overcome this problem, and while everything is recognized in Domino Designer it resulted in lots of NoClassDefFound exceptions after trying to reach my xpage service, despite the jars being in the build path and all.
java.lang.NoClassDefFoundError: net.fortuna.ical4j.data.CalendarBuilder
How can I safely parse this manually, or how can I properly import ical4j jar to my xpage? I just want to modify 3 fields, the DTSTART, DTEND and SUMMARY, with the dates I had no problems so far. Fields like Description are using literal \n string to mark new lines, it should be the same in other fields...
Update
So I have read more about iCalendar, and it seems that there is a standard for this called line folds, these are crlf line endings followed by a space. I made a while loop checking until the last line-break not followed by a space, and it works great so far. Will use this unless there's a better solution (ical4j is one, but I can't get it working with Domino)
Trying to setup a livetemplate for Flutter which is this:
S.of(context).$END$$lowerCaseName$ $lowerCaseName$":$SELECTION$
Where lowerCaseName is camelCase(String). But when I run it, I get an extra " right after $END$
For example, if I select "test string" in my code and surround with the live template, instead of getting this:
String test = S.of(context).TestString TestString":"test string";
I get this:
String test = S.of(context)."TestString "TestString":"test string";
Any ideas?
the problem is that $SELECTION$ value is the whole string you select, including quotes. So you have to strip them somehow. I'd suggest using groovyScript() - see https://www.jetbrains.com/help/idea/edit-template-variables-dialog.html, http://bartololeo.blogspot.com/2014/01/idea-12-how-to-write-live-template-with.html. For example, the following function specified as expression for $lowerCaseName$ should do the thing:
camelCase(groovyScript("_1.replace('\"', '')", SELECTION))
I am pulling text from an embedded .txt file and then displaying it in a label. iOS is fine, but Android shows extra characters. I am missing something simple but not sure what. Thanks for the help.
This (in a .txt file):
0.2.3
- Fixed spelling errors
- Added version number in slide-out menu
- Squashed bugs
0.2.2
- Database Change Log Added.
- Bug Fixes.
0.2.1
- Bug Fixes
Turns into this:
The space characters are bring shown. How do I prevent this?
Retrieving the text:
var assembly = typeof(MainMenuViewModel).GetTypeInfo().Assembly;
Stream stream = assembly.GetManifestResourceStream("ReleaseNotes.txt");
var text = "";
using (var reader = new StreamReader(stream))
{
text = reader.ReadToEnd();
}
ReleseNotesText = text;
The Label:
<Label Text="{Binding ReleseNotesText}" HorizontalTextAlignment="Start" HorizontalOptions="Fill" VerticalOptions="CenterAndExpand" TextColor="{DynamicResource TextColor}" FontSize="18" />
More likely your newlines are \n in the embedded text file stream
Just convert them to the correct environment newline. Newline character(s) may vary depending on the running platform... in .NET you have the handy Environment.NewLine, thus:
ReleseNotesText = text.Replace("\n", Environment.NewLine);
Edit: after taking a look at the exact text file in the comments, it looks like it was using the U+2028 unicode sequence for newlines. The correct replacing code would be:
ReleseNotesText = text.Replace("\u2028", Environment.NewLine);