Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I am trying to use the libphonenumber-csharp library and the FindNumbers feature. But I am unable to implement it properly. What am I doing wrong?
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
var a = phoneUtil.findNumbers("this is my phone number: (805) 527-9975", null);
Console.WriteLine(a);
Console.Write(phoneUtil.findNumbers("8055279975", "US"));
public Iterable<PhoneNumberMatch> findNumbers(CharSequence text, String defaultRegion);
I tried the code and I am getting this as the output:
java.lang.Iterable1[com.google.i18n.phonenumbers.PhoneNumberMatch]
java.lang.Iterable1[com.google.i18n.phonenumbers.PhoneNumberMatch]
Are you getting the same result? looking into the issue now and I'll let you know if I figure it out.
EDIT
I was able to figure it out!
The correct way to do it is like this:
string testString = "testing the ability to grab here: 345-365-567";
{
PhoneNumberUtil phoneUtil = PhoneNumberUtil.GetInstance();
PhoneNumber phoneNumber = phoneUtil.Parse(testString, "US");
//now from here you can do ahead and retrieve the number by calling upon phoneNumber.
Console.WriteLine(phoneNumber.NationalNumber);
}
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 months ago.
Improve this question
Im trying to edit a postcode data which comes as for example 1234567 and i want to put a dash between 123 and 4567 (e.g 123-4567) is it possible to do this within C# without editing the csv file itself?
Im using a generic for loop to read through the csv file but i want to edit it like i asked above.
foreach(string line in csvData_){
string[] col = line.Split(',');
deliveryAddress.Text = col[0];
deliveryPostcode.Text = col[1];
deliveryPostcode contains 1234567 for e.g.
To solve your problem, you can use the method Insert() of the string object.
For example:
deliveryPostcode.Text = col[1].Length == 7 ? col[1].Insert(3, "-") : col[1];
You have to fit it for your needs, but this is the way I would use.
Here is the MSDN page of the String.Insert().
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Convert a string into mac address as example 0000001 need to change as 00:00:01 In php i can get it by this $HexVal=rtrim(strtoupper(chunk_split($hexval, 2, ':')),':'); i need exactly same in C#.
I have the first 6 value as 00:01:AB and i got the last six value from a decimal number. If i input 1 then it needs to change as 00:00:01. so then i con-cat to get my full mac as 00:00:AB:00:00:01.
OK got it,,
var temp = Regex.Replace("000001", ".{2}", "$0:");
var tempo = temp.Remove(temp.Trim().Length - 1);//or
var tempo = temp.Trim(':');
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a string that I am grabbing that is input as:
05/22/2015
Eligibility
05/06/2015
Date of Death
I need 05/06/2015. The dates will change as the program runs through a database, and I am just a little unsure on how to always be grabbing the correct one.
So you need the second date only? Is it always going to be the 3rd line? If so you can do
var secondDate = myData.Split(new [] { Environment.NewLine }, StringSplitOptions.None)[2];
If the new line isn't for certain; /n vs /r/n, use:
var secondDate = myDate.Split(Environment.Newline.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[2];
If I understand you correctly, your string has 4 lines and you want the part of the string between linebreak 2 and 3.
Search for the positions of the second and third linebreak \n and use the substring derived of these positions.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i have textedit1.text it has a value 2 in my winform,..and then i have timedit called timePekerjaanStart value 04:00:00 . the case is i wanna addition between textedit1 and timePekerjaanStart ,i catch the result in timestamp called timePekerjaanEnd. so , i wanna get the result timePekerjaanEnd = textedit1 + timePekerjaanStart as like 2 + 04:00:00 = 06:00:00
You've not provided any attempts to solve it yourself but it's really quite straight forward:
var theHoursToAdd = int.Parse(textedit1.Text); // Error handling needs to be added
var startTime = timePekerjaanStart.Time;
timePekerjaanEnd.Time = startTime.AddHours(theHoursToAdd);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want convert 1,2,3,4,5,6,7,8,9,10 String to Double.
I tried Convert.ToDouble(String); and Double.Parse(String); but returned 1.0
How to convert multi comma string to double?
Thanks for help.
From the looks of your question you actually have 10 numbers not 1. Use this code:
var nums = "1,2,3,4,5,6,7,8,9,10";
var digits = nums.Split(',').Select(r => Convert.ToDouble(r)).ToArray();
// the result will be an array of doubles, also this only works with .NET 3.5 or better.
Let me know if this works for you.