Dart: Find first digit in String and cut the String - date

I have a string like this:
"tuesday 04.08.2020" or
"wednesday 05.08.2020"
and i will cut the day (tuesday or wednesday) so that my string is in the following format:
"04.08.2020" or
"05.08.2020"
How can i found the first digit in a string and become this format. I don't have found a solution in dart yet. In other languages (e.g. javascript or python) it gives a search function, but in the dart language i don't find a function like this. Can anyone help me please?

You may not need to find the first digit.
This will work
String a = "tuesday 04.08.2020";
String date = a.split(" ").last;
print(date);//04.08.2020

Related

Dart encodeFull issue

When i encode an uri from integer to string. Dart put this %E2%80%8B value before number. What is the reason? Why the dart put this value before number? I can't send parameters from url like that.
const number = 15;
String uri = Uri.encodeFull("https://google.com/${number}");
print(uri);
i got this output https://google.com/15%E2%80%8B why ?? check the link there is a space end of uri. When it work like this i can't call the api because its not a integer value.
İs it a bug or something?
%E2%80%8B represents a sequence of hexadecimal bytes E2, 80, 8B. That sequence corresponds to the UTF-8 representation of the Unicode "zero width space" character (U+200B).
I suspect that you copied and pasted your string from somewhere and inadvertently included an invisible Unicode character. Deleting and retyping the last portion of your "https://google.com/${number}" string literal should fix the problem.
Please add more info, I Have tested your code it's behaving normally.
var number=1234;
var k=Uri.encodeFull("https://google.com/${number}");
Output: https://google.com/1234

Cakephp 3 i18nFormat string for the number of weeks in a specified date

How to get number of week for specific date in cakephp 3?
$this->mydate->i18nFormat('yyyy-MM-dd') will display year-month-date.
But what about string format for week number?
Thanks.
Have a closer look at the docs for Cake\I18n\Time::i18nFormat(), it tells you what you can pass as the format, and where to find a list of the accepted formatting patterns:
[...] You can either pass IntlDateFormatter constants as the first
argument of this function, or pass a full ICU date formatting string
as specified in the following resource:
https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax.
Cookbook > Date & Time > Formatting > Cake\I18n\Time::i18nFormat()
So long story short, the pattern letter for the week of the year is w, or ww if you want a leading zero, and for the week of the month it's W or WW.

crystal reports - how to extract a date from string

Using Crystal Reports 2008, I need to extract a date from a text field. This date is usually in the format dd/mm/yy, but could also be entered as d/m/yy, dd/m/yyyy, etc.
This date could appear anywhere within the string.
At the moment I am relying on the fact that the date is placed at the end of the string, without a following fullstop, and using LEFT/RIGHT to extract each date part. These parts are then passed to another formula to create a full date:
Dim AllocationDate() as Date
If Not(IsNull({Command.Notes})) then
Formula = DateValue ((ToNumber ({#Year})), (ToNumber ({#Month})), (ToNumber ({#Day})))
However, if anyone uses a variation of format, adds a fullstop or more notes after the date the whole report keels over.
Is there any way I could extract this date by looking for a pattern? I'm guessing I could the use TRIM to get around the inconsistencies in format.
tyvmia
You may want to consider using a regular expression.
Crystal Reports doesn't have native support for regular expressions, so you'll need to add a UFL: crystal reports : is there a way to regex in crystal reports?
You should be able to adapt the pattern in this question for your needs: Javascript date regex DD/MM/YYYY
Finally, you can test the pattern on your text using regexpal.com.
** edit **
Create a SQL-expression field (Oracle 10 syntax) to extract date string and convert it to a date field:
// {%Allocation Date}
(
-- match date-like string, then convert to date type; is no dates are found, NULL is returned
TO_DATE( REGEXP_SUBSTR( TABLE.FIELD, '\d{1,2}\/\d{1,2}\/\d{2,4}',1 ,1), 'dd/mm/yyyy')
)
While you could
And, as a last resort, you can try converting the multi-line string into a long string by replacing the special characters that represent CR, LF, etc. Replacing them with spaces or another innocuous character, and then treat the resultant string as if it were just a regular string (with the date in the middle).
You would still have to make some assumptions to make this possible: ONE date per string, all special characters are known (or you have to test for all possible special characters), the date has SOME conformity to the format, etc.

String to Unicode in C#

I want to use Unicode in my code. My Unicode value is 0100 and I am adding my Unicode string \u with my value. When I use string myVal="\u0100", it's working, but when I use like below, it's not working. The value is looking like "\\u1000";. How do I resolve this?
I want to use it like the below one, because the Unicode value may vary sometimes.
string uStr=#"\u" + "0100";
There are a couple of problems here. One is that #"\u" is actually the literal string "\u" (can also be represented as "\u").
The other issue is that you cannot construct a string in the way you describe because "\u" is not a valid string by itself. The compiler is expecting a value to follow "\u" (like "\u0100") to determine what the encoded value is supposed to be.
You need to keep in mind that strings in .NET are immutable, which means that when you look at what is going on behind the scenes with your concatenated example (`#"\u"+"0100"), this is what is actually happening:
Create the string "\u"
Create the string "0100"
Create the string "\u0100"
So you have three strings in memory. In order for that to happen all of the strings must be valid.
The first option that comes to mind for handling those values is to actually parse them as integers, and then convert them to characters. Something like:
var unicodeValue = (char)int.Parse("0100",System.Globalization.NumberStyles.AllowHexSpecifier);
Which will give you the single Unicode character value. From there, you can add it to a string, or convert it to a string using ToString().

crystal reports : substring error

I've developed a workaround since crystal reports doesn't seem to have a substring function with the following formula:
right({_v_hardware.groupname},
truncate(instr(replace({_v_hardware.groupname},".",
","), ","))
What I'm trying to do is search for the period (".") in a string and replace it with a comma. Then find the comma position in the string and print all characters following after the comma. This is assuming the string will only have 1 period in the entire string.
Now when I attempt to do this, I get some weird characters which look like wingdings. Any ideas?
thanks in advance.
I don't know the entire issue that you are attempting to accomplish, but for this question alone, the step of replacing the period with a comma seems to be unnecessary. If you know that there is only one period in the string and you only want the characters right of the period then you should be able to do something like the following (this is #first_formula):
right({_v_hardware.groupname}, len({_v_hardware.groupname}) - instr({_v_hardware.groupname},"."))
If for some reason you want to show the comma then I'd do that in a separate formula. If you need the entire screen with the comma replaced then just do:
replace({_v_hardware.groupname},".",",")
And if you need the comma plus included in the string then it might just be easier to do something like:
"," + {#first_formula}
Hope this helps.