|
"DNo:12,Crystal Building,ghn O M R Road; 5 e c r road; c/o r g rao";
that bold part alone has errors it shows 5ecr...
i told you numeric values should not be included even if it is single... could u fix it out
thanks for your help
the quieter u become more u hear
|
|
|
|
|
lawrenceinba wrote: that bold part alone has errors it shows 5ecr...
No, it doesn't. Look at the output that I posted.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
please try this input
"DNo:12,Crystal Building, behind O M R Road; 5 e c r road; c/o r g rao"
the output merges 5ecr
the quieter u become more u hear
|
|
|
|
|
great conversation, keep it up!
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Yes, that does give a different output. Use this pattern:
(?<= )([A-Za-z]) (?=[A-Za-z] )
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
before rebuild my project its work properly But if rebuild it then gives error for each form.
The error is -
Unable to copy file "obj\Debug\Hospital.frmAddMedicine.resources" to "obj\Debug\Hospital.obj.Debug.Hospital.frmAddMedicine.resources". Could not find file 'obj\Debug\Hospital.frmAddMedicine.resources'. Hospital
But before rebuild the project all the resource file was present. Please help me.
|
|
|
|
|
Clean then rebuild.
maybe you have a couple of files' attributes set to read-only.
you can get rid of the obj folder each time you rebuild, no worry.
|
|
|
|
|
I am developing an sms application, whenever the application receive an sms it is assigned to a string. the string value is something like this:
+CMT:"+658208342",,"09/02/08",16:15:22+50"<br />
Test Message from coder
String text = (above code lines)
i have to take the Mobile number, datetime , and text as 3 different string from the above string.
Now what i had is that i use split whenever a string have " and then add it to an array
string s = text.Replace(",,", "");
string[] values = s.Split(new char[] { '"' });
string incoming_msg_number = values[1];
Thread.Sleep(50);
string msg_date_time = values[3];
Thread.Sleep(50);
string msg_text = values[4].Trim();
MessageBox.Show("Number :" + incoming_msg_number + " \r\nDate & Time: " + msg_date_time +
"\r\nMessage :" + msg_text);*
It DIDNT work because there are chances of quaotes within the incoming message
Will regex can do something with this?? if so how??
thanks....
|
|
|
|
|
Aghosh Babu wrote: +CMT:"+658208342",,"09/02/08",16:15:22+50"
Test Message from coder
Are they on two separate lines? In other words, is that an '\n' character I see within the string?
I are troll
|
|
|
|
|
|
+CMT:"+658208342",,"09/02/08",16:15:22+50"
Test "Message" from coder
So, this would fail, since there are quotes on the second line?
Would it help if you split the string based on the NewLine first? Something like this;
string[] Message = s.Split('\n');
This will put the first line in Message[0], and the text-message in Message[1]. You can then safely split your values on the quotes like;
string[] values = Message[0].Split(new char[] { '"' });
HTH
I are troll
|
|
|
|
|
hi thanks, but i cant split with quotes because the incoming SMS may contain quotes too...! any other method other than split??
|
|
|
|
|
The incoming SMS will contain quotes on the second line? If so, there shouldn't be any problem splitting them once you have separated the first and the second line? In other words, Split only on "line 1", without touching line 2:
+CMT:
+658208342
09/02/08
,16:15:22+50
and
Test "Message' from coder
There are lots of methods to manipulate strings, including, but not limited to, regular expressions, the internal string-routines (Substring, IndexOfAny), parsers..
I are troll
|
|
|
|
|
|
I would use a Regular Expression to split the string. Is it always two lines per message? Or sometimes more?
This
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex
(
"(?'A'[^:]*):\"(?'B'[^\"]*)\",,\"(?'C'[^\"]*)\",(?'D'[^\"]*)\"\n(?'E'[^\n]*)\n"
,
System.Text.RegularExpressions.RegexOptions.Compiled |
System.Text.RegularExpressions.RegexOptions.Singleline |
System.Text.RegularExpressions.RegexOptions.CultureInvariant
) ;
is giving me:
A >+CMT<
B >+658208342<
C >09/02/08<
D >16:15:22+50<
E >Test Message from coder<
Did you leave out a quote in your data?
modified on Sunday, February 8, 2009 9:21 AM
|
|
|
|
|
its always 2 lines. is the A,B,C,D,E strings ? can i call these strings later within the method?? Thanks alott. .
|
|
|
|
|
Those are groups, and yes you can access then by name.
If you have a class/struct to hold the data
MyObject objX ;
foreach ( System.Text.RegularExpressions.Match mat in reg.Matches ( text ) )
{
objX = new MyObject
(
mat.Groups [ "A" ].Value
,
mat.Groups [ "B" ].Value
,
mat.Groups [ "C" ].Value
,
mat.Groups [ "D" ].Value
,
mat.Groups [ "E" ].Value
) ;
}
And parse the values in the constructor. That's just one way.
|
|
|
|
|
if u dont mind can u pls explain me how i combine those codes?? where should i add the string?? how i retreive the strings from the regex and display it in a msg box?? thanks a lott... i am a beginer in C#...
|
|
|
|
|
|
You can limit the number of items that the Split returns, so that you get everything after the fifth quotation mark in the sixth item:
string[] values = s.Split(new char[] { '"' }, 6);
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
how to receive a frame from serilal port
I want to receive a frame that this frame has CRC start bit ,stop bitplz help to me that how to start this work
|
|
|
|
|
|
Hi, i got some problem here reading my XML using DOM method.
This is my XML file
<invoice>
<number>INV-4773-282009</number>
<date>2/8/2009</date>
<sellerid>2828</sellerid>
<buyerid>2828</buyerid>
<orderid>PO-565029-282009</orderid>
<billingaddress>123 Tampines St 1 #01-55</billingaddress>
<orderitems>
<item>
<productid>P-0003</productid>
<quantity>3</quantity>
<unitprice>42</unitprice>
<description>OCZ Ram</description>
</item>
</orderitems>
</invoice>
This is my code for reading the code
<code>invoiceDoc = new XmlDocument();
invoiceDoc.Load(windir + "\\" + lstFiles.SelectedItem.ToString() + ".xml");
string invNumber = null;
string invDate = null;
string invSellerID = null;
string invBuyerID = null;
string invOrderID = null;
string invBillAddress = null;
string invProductID = null;
string invProductQty = null;
double invUnitPrice = 0.0;
string invProductDesc = null;
XmlNodeList invList = invoiceDoc.GetElementsByTagName("Invoice");
foreach (XmlNode node in invList)
{
if (node.HasChildNodes)
{
XmlElement childNode = (XmlElement)node.FirstChild;
for (int i = 0; i < node.ChildNodes.Count; i++)
{
switch (childNode.Name)
{
case "Number":
invNumber = childNode.InnerText;
break;
case "Date":
invDate = childNode.InnerText;
break;
case "SellerID":
invSellerID = childNode.InnerText;
break;
case "BuyerID":
invBuyerID = childNode.InnerText;
break;
case "OrderID":
invOrderID = childNode.InnerText;
break;
case "BillingAddress":
invBillAddress = childNode.InnerText;
break;
case "ProductID":
invProductID = childNode.InnerText;
break;
default:
break;
}
childNode = (XmlElement)childNode.NextSibling;
}
}
}</code>
<b>Problem : when it comes to productID, it got problem reading. I got nullreferenceexception </b>
<div class="ForumMod">modified on Sunday, February 8, 2009 3:11 AM</div>
|
|
|
|
|
Your XML doesn't show up. Use the "Ignore HTML" option when posting markup code.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|