Search Results

Search found 36065 results on 1443 pages for 'string manipulation'.

Page 13/1443 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • XML Serializing a class with a Dictionary<string, List<string>> object

    - by Matt
    Is it possible to implement IXmlSerializable and in my XML file capture an object of type Dictionary ? I have the following public class coolio : IXmlSerializable { private int a; private bool b; private string c; private Dictionary<string, List<string>> coco; public coolio(int _a, bool _b, string _c, Dictionary<string, List<string>> _coco) { a=_a; b=_b; c=_c; coco=_coco; } public System.Xml.Schema.XmlSchema GetSchema() { return null; } public void WriteXml(XmlWriter writer) { const string myType = "coolio"; writer.WriteStartElement(myType); writer.WriteAttributeString("a", a.ToString()); writer.WriteAttributeString("b", b.ToString()); writer.WriteAttributeString("c", c); // How do I add a subelement for Dictionary<string, List<string>> coco? writer.WriteEndElement(); } public void ReadXml(XmlReader reader) { if (reader.MoveToContent() != XmlNodeType.Element || reader.LocalName != "coolio") return; a= int.Parse(reader["a"]); b = bool.Parse(reader["b"]); c= reader["c"]; // How do I read subelement into Dictionary<string, List<string>> coco? } } But I am stumped as to how I could add the Dictionary (XML seriliazed to my XML file)

    Read the article

  • Avoiding resource (localizable string) duplication with String.Format

    - by Hrvoje Prgeša
    I'm working on a application (.NET, but not relevant) where there is large potential for resource/string duplication - most of these strings are simple like: Volume: 33 Volume: 33 (dB) Volume 33 dB Volume (dB) Command - Volume: 33 (dB) where X, Y and unit are the same. Should I define a new resource for each of the string or is it preferable to use String.Format to simplify some of these, eg.: String.Format("{0}: {1}", Resource.Volume, 33) String.Format("{0}: {1} {2}", Resource.Volume, 33, Resource.dB) Resource.Volume String.Format("{0} ({1})", 33, Resource.dB) String.Format("{0} ({1})", Resource.Volume, Resource.dB) String.Format("Command - {0}: {1} {2}", Resource.Volume, 33, Resource.dB) I would also define string formats like "{0}: {1}" in the resources so there would be a possibility of reordering words... I would not use this approach selectivly and not throughout the whole application.. And how about: String.Format("{0}: {1}", Volume, Resource.Muted_Volume) // = Volume: Muted Resource.Muted_Volume String.Format("{0}: {1} (by user {2})", Volume, Resource.Muted_Volume, "xy") // = Volume: Muted (by user xy) The advantage is cutting the number of resource by the factor of 4-5. Are there any hidden dangers of using this approach? Could someone give me an example (language) where this would not work correctly?

    Read the article

  • c++ creating ambigram from string

    - by mike_hornbeck
    I have a task to implement "void makeAmbigram(char*)" that will print on screen ambigram of latin string or return something like 'ambigram not possible'. Guess it's just about checking if string contains only of SNOXZHI and printing string backwards. Or am I wrong ? I'm a complete noob when dealing with cpp so that's what I've created : #include <iostream> using namespace std; char[]words; char[]reversed; char[] ret_str(char* s) { if(*s != '\0') ret_str(s+1); return s; } void makeAmbigram(char* c) { /* finding chars XIHNOZS and printing ambigram */ } int main() { cin>>words; reversed = ret_str(words); makeAmbigram(reversed); return 0; } I can reverse string but how to check if my reversed string contains only needed chars ? I've found some function but it's hard or even imposible to implement it for greater amount of chars : http://www.java2s.com/Code/C/String/Findcharacterinstringhowtousestrchr.htm

    Read the article

  • Optimizing a lot of Scanner.findWithinHorizon(pattern, 0) calls

    - by darvids0n
    I'm building a process which extracts data from 6 csv-style files and two poorly laid out .txt reports and builds output CSVs, and I'm fully aware that there's going to be some overhead searching through all that whitespace thousands of times, but I never anticipated converting about about 50,000 records would take 12 hours. Excerpt of my manual matching code (I know it's horrible that I use lists of tokens like that, but it was the best thing I could think of): public static String lookup(List<String> tokensBefore, List<String> tokensAfter) { String result = null; while(_match(tokensBefore)) { // block until all input is read if(id.hasNext()) { result = id.next(); // capture the next token that matches if(_matchImmediate(tokensAfter)) // try to match tokensAfter to this result return result; } else return null; // end of file; no match } return null; // no matches } private static boolean _match(List<String> tokens) { return _match(tokens, true); } private static boolean _match(List<String> tokens, boolean block) { if(tokens != null && !tokens.isEmpty()) { if(id.findWithinHorizon(tokens.get(0), 0) == null) return false; for(int i = 1; i <= tokens.size(); i++) { if (i == tokens.size()) { // matches all tokens return true; } else if(id.hasNext() && !id.next().matches(tokens.get(i))) { break; // break to blocking behaviour } } } else { return true; // empty list always matches } if(block) return _match(tokens); // loop until we find something or nothing else return false; // return after just one attempted match } private static boolean _matchImmediate(List<String> tokens) { if(tokens != null) { for(int i = 0; i <= tokens.size(); i++) { if (i == tokens.size()) { // matches all tokens return true; } else if(!id.hasNext() || !id.next().matches(tokens.get(i))) { return false; // doesn't match, or end of file } } return false; // we have some serious problems if this ever gets called } else { return true; // empty list always matches } } Basically wondering how I would work in an efficient string search (Boyer-Moore or similar). My Scanner id is scanning a java.util.String, figured buffering it to memory would reduce I/O since the search here is being performed thousands of times on a relatively small file. The performance increase compared to scanning a BufferedReader(FileReader(File)) was probably less than 1%, the process still looks to be taking a LONG time. I've also traced execution and the slowness of my overall conversion process is definitely between the first and last like of the lookup method. In fact, so much so that I ran a shortcut process to count the number of occurrences of various identifiers in the .csv-style files (I use 2 lookup methods, this is just one of them) and the process completed indexing approx 4 different identifiers for 50,000 records in less than a minute. Compared to 12 hours, that's instant. Some notes (updated): I don't necessarily need the pattern-matching behaviour, I only get the first field of a line of text so I need to match line breaks or use Scanner.nextLine(). All ID numbers I need start at position 0 of a line and run through til the first block of whitespace, after which is the name of the corresponding object. I would ideally want to return a String, not an int locating the line number or start position of the result, but if it's faster then it will still work just fine. If an int is being returned, however, then I would now have to seek to that line again just to get the ID; storing the ID of every line that is searched sounds like a way around that. Anything to help me out, even if it saves 1ms per search, will help, so all input is appreciated. Thankyou! Usage scenario 1: I have a list of objects in file A, who in the old-style system have an id number which is not in file A. It is, however, POSSIBLY in another csv-style file (file B) or possibly still in a .txt report (file C) which each also contain a bunch of other information which is not useful here, and so file B needs to be searched through for the object's full name (1 token since it would reside within the second column of any given line), and then the first column should be the ID number. If that doesn't work, we then have to split the search token by whitespace into separate tokens before doing a search of file C for those tokens as well. Generalised code: String field; for (/* each record in file A */) { /* construct the rest of this object from file A info */ // now to find the ID, if we can List<String> objectName = new ArrayList<String>(1); objectName.add(Pattern.quote(thisObject.fullName)); field = lookup(objectSearchToken, objectName); // search file B if(field == null) // not found in file B { lookupReset(false); // initialise scanner to check file C objectName.clear(); // not using the full name String[] tokens = thisObject.fullName.split(id.delimiter().pattern()); for(String s : tokens) objectName.add(Pattern.quote(s)); field = lookup(objectSearchToken, objectName); // search file C lookupReset(true); // back to file B } else { /* found it, file B specific processing here */ } if(field != null) // found it in B or C thisObject.ID = field; } The objectName tokens are all uppercase words with possible hyphens or apostrophes in them, separated by spaces. Much like a person's name. As per a comment, I will pre-compile the regex for my objectSearchToken, which is just [\r\n]+. What's ending up happening in file C is, every single line is being checked, even the 95% of lines which don't contain an ID number and object name at the start. Would it be quicker to use ^[\r\n]+.*(objectname) instead of two separate regexes? It may reduce the number of _match executions. The more general case of that would be, concatenate all tokensBefore with all tokensAfter, and put a .* in the middle. It would need to be matching backwards through the file though, otherwise it would match the correct line but with a huge .* block in the middle with lots of lines. The above situation could be resolved if I could get java.util.Scanner to return the token previous to the current one after a call to findWithinHorizon. I have another usage scenario. Will put it up asap.

    Read the article

  • How Do I Parse a String?

    - by Russ
    I am new to bash, and I am creating a script that loops through the files in a directory and based on part of the filename, does something with the file, so far I have this: #!/bin/bash DIR="/Users/me/Documents/import/*" for f in "$DIR" do $t=?????? echo "Loading $f int $t..." done so $f will output something like this: /Users/me/Documents/import/time_dim-1272037430173 out of this, I want time_dim, the directory can be variable length and -1272037430173 is a fixed length (it's the unix timestamp btw). What is the best way to go about this?

    Read the article

  • AdvancedFormatProvider: Making string.format do more

    - by plblum
    When I have an integer that I want to format within the String.Format() and ToString(format) methods, I’m always forgetting the format symbol to use with it. That’s probably because its not very intuitive. Use {0:N0} if you want it with group (thousands) separators. text = String.Format("{0:N0}", 1000); // returns "1,000"   int value1 = 1000; text = value1.ToString("N0"); Use {0:D} or {0:G} if you want it without group separators. text = String.Format("{0:D}", 1000); // returns "1000"   int value2 = 1000; text2 = value2.ToString("D"); The {0:D} is especially confusing because Microsoft gives the token the name “Decimal”. I thought it reasonable to have a new format symbol for String.Format, "I" for integer, and the ability to tell it whether it shows the group separators. Along the same lines, why not expand the format symbols for currency ({0:C}) and percent ({0:P}) to let you omit the currency or percent symbol, omit the group separator, and even to drop the decimal part when the value is equal to the whole number? My solution is an open source project called AdvancedFormatProvider, a group of classes that provide the new format symbols, continue to support the rest of the native symbols and makes it easy to plug in additional format symbols. Please visit https://github.com/plblum/AdvancedFormatProvider to learn about it in detail and explore how its implemented. The rest of this post will explore some of the concepts it takes to expand String.Format() and ToString(format). AdvancedFormatProvider benefits: Supports {0:I} token for integers. It offers the {0:I-,} option to omit the group separator. Supports {0:C} token with several options. {0:C-$} omits the currency symbol. {0:C-,} omits group separators, and {0:C-0} hides the decimal part when the value would show “.00”. For example, 1000.0 becomes “$1000” while 1000.12 becomes “$1000.12”. Supports {0:P} token with several options. {0:P-%} omits the percent symbol. {0:P-,} omits group separators, and {0:P-0} hides the decimal part when the value would show “.00”. For example, 1 becomes “100 %” while 1.1223 becomes “112.23 %”. Provides a plug in framework that lets you create new formatters to handle specific format symbols. You register them globally so you can just pass the AdvancedFormatProvider object into String.Format and ToString(format) without having to figure out which plug ins to add. text = String.Format(AdvancedFormatProvider.Current, "{0:I}", 1000); // returns "1,000" text2 = String.Format(AdvancedFormatProvider.Current, "{0:I-,}", 1000); // returns "1000" text3 = String.Format(AdvancedFormatProvider.Current, "{0:C-$-,}", 1000.0); // returns "1000.00" The IFormatProvider parameter Microsoft has made String.Format() and ToString(format) format expandable. They each take an additional parameter that takes an object that implements System.IFormatProvider. This interface has a single member, the GetFormat() method, which returns an object that knows how to convert the format symbol and value into the desired string. There are already a number of web-based resources to teach you about IFormatProvider and the companion interface ICustomFormatter. I’ll defer to them if you want to dig more into the topic. The only thing I want to point out is what I think are implementation considerations. Why GetFormat() always tests for ICustomFormatter When you see examples of implementing IFormatProviders, the GetFormat() method always tests the parameter against the ICustomFormatter type. Why is that? public object GetFormat(Type formatType) { if (formatType == typeof(ICustomFormatter)) return this; else return null; } The value of formatType is already predetermined by the .net framework. String.Format() uses the StringBuilder.AppendFormat() method to parse the string, extracting the tokens and calling GetFormat() with the ICustomFormatter type. (The .net framework also calls GetFormat() with the types of System.Globalization.NumberFormatInfo and System.Globalization.DateTimeFormatInfo but these are exclusive to how the System.Globalization.CultureInfo class handles its implementation of IFormatProvider.) Your code replaces instead of expands I would have expected the caller to pass in the format string to GetFormat() to allow your code to determine if it handles the request. My vision would be to return null when the format string is not supported. The caller would iterate through IFormatProviders until it finds one that handles the format string. Unfortunatley that is not the case. The reason you write GetFormat() as above is because the caller is expecting an object that handles all formatting cases. You are effectively supposed to write enough code in your formatter to handle your new cases and call .net functions (like String.Format() and ToString(format)) to handle the original cases. Its not hard to support the native functions from within your ICustomFormatter.Format function. Just test the format string to see if it applies to you. If not, call String.Format() with a token using the format passed in. public string Format(string format, object arg, IFormatProvider formatProvider) { if (format.StartsWith("I")) { // handle "I" formatter } else return String.Format(formatProvider, "{0:" + format + "}", arg); } Formatters are only used by explicit request Each time you write a custom formatter (implementer of ICustomFormatter), it is not used unless you explicitly passed an IFormatProvider object that supports your formatter into String.Format() or ToString(). This has several disadvantages: Suppose you have several ICustomFormatters. In order to have all available to String.Format() and ToString(format), you have to merge their code and create an IFormatProvider to return an instance of your new class. You have to remember to utilize the IFormatProvider parameter. Its easy to overlook, especially when you have existing code that calls String.Format() without using it. Some APIs may call String.Format() themselves. If those APIs do not offer an IFormatProvider parameter, your ICustomFormatter will not be available to them. The AdvancedFormatProvider solves the first two of these problems by providing a plug-in architecture.

    Read the article

  • How can I partial compare two strings in C?

    - by Nazgulled
    Hi, Let's say I have the following content: Lorem Ipsum is simply dummy text of the printing and typesetting industry. How do I search for dummy or dummy text in that string using C? Is there any easy way to do it or only with strong string manipulation? All I need is to search for it and return a boolean with the result.

    Read the article

  • loading xml into SQL Server 2008 using sqlbulkload component

    - by mohamed
    "Error: Schema: relationship expected on 'headerRecord'." I get the above error while load xml file to SQL Server 2008 using SQLXMLBulkLoad4 Component , the xml file contains Call Detail records, I have generated schema file from xml file using both , Dataset and XSD.exe tool, but the error remains same., if there is another way to imports xml file with multiple tables that have relationship in each file into SQL Server 2008? . Here the xml file: <CallEventDataFile> <headerRecord> <productionDateTime>0912021247482B0300</productionDateTime> <recordingEntity>00</recordingEntity> <extensions/> </headerRecord> <callEventRecords> <mtSMSRecord> <recordType>7</recordType> <serviceCentre>91521230</serviceCentre> <servedIMSI>36570000031728F2</servedIMSI> <servedIMEI>53886000707896F0</servedIMEI> <servedMSISDN>915212454503F2</servedMSISDN> <msClassmark>3319A1</msClassmark> <recordingEntity>915212110100</recordingEntity> <location> <locationAreaCode>0006</locationAreaCode> <cellIdentifier>0C6E</cellIdentifier> </location> <deliveryTime>0912021535412B0300</deliveryTime> <systemType> <gERAN/> </systemType> <basicService> <teleservice>21</teleservice> </basicService> <additionalChgInfo> <chargeIndicator>2</chargeIndicator> </additionalChgInfo> <chargedParty> <calledParty/> </chargedParty> <orgRNCorBSCId>8E1A</orgRNCorBSCId> <orgMSCId>921A</orgMSCId> <globalAreaID>36F70500060C6E</globalAreaID> <subscriberCategory>0A</subscriberCategory> <firstmccmnc>36F705</firstmccmnc> <smsUserDataType>FF</smsUserDataType> <origination>8191F2</origination> <callReference>1605EB2FE1</callReference> </mtSMSRecord> <moSMSRecord> <recordType>6</recordType> <servedIMSI>36570000238707F9</servedIMSI> <servedIMEI>53928320195925F0</servedIMEI> <servedMSISDN>915212159430F2</servedMSISDN> <msClassmark>3319A2</msClassmark> <serviceCentre>91521230</serviceCentre> <recordingEntity>915212110100</recordingEntity> <location> <locationAreaCode>001B</locationAreaCode> <cellIdentifier>6983</cellIdentifier> </location> <messageReference>01</messageReference> <originationTime>0912021535412B0300</originationTime> <destinationNumber>8111F1</destinationNumber> <systemType> <gERAN/> </systemType> <basicService> <teleservice>22</teleservice> </basicService> <additionalChgInfo> <chargeIndicator>2</chargeIndicator> </additionalChgInfo> <chargedParty> <callingParty/> </chargedParty> <orgRNCorBSCId>8F1A</orgRNCorBSCId> <orgMSCId>921A</orgMSCId> <globalAreaID>36F705001B6983</globalAreaID> <subscriberCategory>0A</subscriberCategory> <firstmccmnc>36F705</firstmccmnc> <smsUserDataType>FF</smsUserDataType> <callReference>1701BED4FF</callReference> </moSMSRecord> <ssActionRecord> <recordType>10</recordType> <servedIMSI>36570000636448F8</servedIMSI> <servedIMEI>53246030714961F0</servedIMEI> <servedMSISDN>915212056928F8</servedMSISDN> <msClassmark>3018A1</msClassmark> <recordingEntity>915212110100</recordingEntity> <location> <locationAreaCode>000C</locationAreaCode> <cellIdentifier>05A5</cellIdentifier> </location> <supplService>FF</supplService> <ssAction> <ussdInvocation/> </ssAction> <ssActionTime>0912021535412B0300</ssActionTime> <ssParameters> <unstructuredData>AA5C2E3702</unstructuredData> </ssParameters> <callReference>1701BED500</callReference> <systemType> <gERAN/> </systemType> <ussdCodingScheme>0F</ussdCodingScheme> <ussdString> <UssdString>AA5C2E3702</UssdString> </ussdString> <ussdRequestCounter>1</ussdRequestCounter> <additionalChgInfo> <chargeIndicator>1</chargeIndicator> </additionalChgInfo> <orgRNCorBSCId>8E1A</orgRNCorBSCId> <orgMSCId>921A</orgMSCId> <globalAreaID>36F705000C05A5</globalAreaID> <subscriberCategory>0A</subscriberCategory> <firstmccmnc>36F705</firstmccmnc> </ssActionRecord> <moCallRecord> <recordType>0</recordType> <servedIMSI>36570000807501F5</servedIMSI> <servedIMEI>53246030713955F0</servedIMEI> <servedMSISDN>915212157901F0</servedMSISDN> <callingNumber>A151911700</callingNumber> <calledNumber>8151677589</calledNumber> <roamingNumber>A111113850</roamingNumber> <recordingEntity>915212110100</recordingEntity> <mscIncomingROUTE> <rOUTEName>HWBSC2</rOUTEName> </mscIncomingROUTE> <mscOutgoingROUTE> <rOUTEName>HWBSC2</rOUTEName> </mscOutgoingROUTE> <location> <locationAreaCode>0006</locationAreaCode> <cellIdentifier>0C2F</cellIdentifier> </location> <basicService> <teleservice>11</teleservice> </basicService> <msClassmark>3319A1</msClassmark> <answerTime>0912021535382B0300</answerTime> <releaseTime>0912021535422B0300</releaseTime> <callDuration>4</callDuration> <radioChanRequested> <dualFullRatePreferred/> </radioChanRequested> <radioChanUsed> <halfRate/> </radioChanUsed> <causeForTerm>0</causeForTerm> <diagnostics> <gsm0408Cause>144</gsm0408Cause> </diagnostics> <callReference>1701BED501</callReference> <additionalChgInfo> <chargeIndicator>2</chargeIndicator> </additionalChgInfo> <gsm-SCFAddress>915212110130</gsm-SCFAddress> <serviceKey>1</serviceKey> <networkCallReference>171D555132</networkCallReference> <mSCAddress>915212110100</mSCAddress> <speechVersionSupported>25</speechVersionSupported> <speechVersionUsed>21</speechVersionUsed> <numberOfDPEncountered>3</numberOfDPEncountered> <levelOfCAMELService>01</levelOfCAMELService> <freeFormatData>800130</freeFormatData> <systemType> <gERAN/> </systemType> <classmark3>C000</classmark3> <chargedParty> <callingParty/> </chargedParty> <mscOutgoingCircuit>1051</mscOutgoingCircuit> <orgRNCorBSCId>8E1A</orgRNCorBSCId> <orgMSCId>921A</orgMSCId> <calledIMSI>36570000635618F8</calledIMSI> <globalAreaID>36F70500060C2F</globalAreaID> <subscriberCategory>0A</subscriberCategory> <firstmccmnc>36F705</firstmccmnc> <lastmccmnc>36F705</lastmccmnc> </moCallRecord> <mtCallRecord> <recordType>1</recordType> <servedIMSI>36570000635618F8</servedIMSI> <servedIMEI>53464010474309F0</servedIMEI> <servedMSISDN>915212755697F8</servedMSISDN> <callingNumber>A151911700</callingNumber> <recordingEntity>915212110100</recordingEntity> <mscIncomingROUTE> <rOUTEName>HWBSC2</rOUTEName> </mscIncomingROUTE> <mscOutgoingROUTE> <rOUTEName>HWBSC2</rOUTEName> </mscOutgoingROUTE> <location> <locationAreaCode>0006</locationAreaCode> <cellIdentifier>0C2D</cellIdentifier> </location> <basicService> <teleservice>11</teleservice> </basicService> <supplServicesUsed> <SuppServiceUsedid> <ssCode>11</ssCode> <ssTime>0912021535382B0300</ssTime> </SuppServiceUsedid> </supplServicesUsed> <msClassmark>331981</msClassmark> <answerTime>0912021535382B0300</answerTime> <releaseTime>0912021535422B0300</releaseTime> <callDuration>4</callDuration> <radioChanRequested> <dualFullRatePreferred/> </radioChanRequested> <radioChanUsed> <halfRate/> </radioChanUsed> <causeForTerm>0</causeForTerm> <diagnostics> <gsm0408Cause>144</gsm0408Cause> </diagnostics> <callReference>1701BED502</callReference> <additionalChgInfo> <chargeIndicator>2</chargeIndicator> </additionalChgInfo> <networkCallReference>171D555132</networkCallReference> <mSCAddress>915212110100</mSCAddress> <speechVersionSupported>25</speechVersionSupported> <speechVersionUsed>21</speechVersionUsed> <systemType> <gERAN/> </systemType> <classmark3>C000</classmark3> <chargedParty> <calledParty/> </chargedParty> <roamingNumber>A111113850</roamingNumber> <mscIncomingCircuit>9119</mscIncomingCircuit> <orgRNCorBSCId>8E1A</orgRNCorBSCId> <orgMSCId>921A</orgMSCId> <globalAreaID>36F70500060C2D</globalAreaID> <subscriberCategory>0A</subscriberCategory> <firstmccmnc>36F705</firstmccmnc> <lastmccmnc>36F705</lastmccmnc> </mtCallRecord> <incGatewayRecord> <recordType>3</recordType> <callingNumber>A17005991565</callingNumber> <calledNumber>A1853643F7</calledNumber> <recordingEntity>915212110100</recordingEntity> <mscIncomingROUTE> <rOUTEName>ZPSTN</rOUTEName> </mscIncomingROUTE> <mscOutgoingROUTE> <rOUTEName>ZTEBSC3</rOUTEName> </mscOutgoingROUTE> <answerTime>0912021535302B0300</answerTime> <releaseTime>0912021535422B0300</releaseTime> <callDuration>12</callDuration> <causeForTerm>0</causeForTerm> <diagnostics> <gsm0408Cause>144</gsm0408Cause> </diagnostics> <callReference>2203AFBF84</callReference> <basicService> <teleservice>11</teleservice> </basicService> <additionalChgInfo> <chargeIndicator>2</chargeIndicator> </additionalChgInfo> <roamingNumber>A111111980</roamingNumber> <mscIncomingCircuit>934</mscIncomingCircuit> <orgMSCId>921A</orgMSCId> <mscIncomingRouteAttribute> <isup/> </mscIncomingRouteAttribute> <networkCallReference>22432B5132</networkCallReference> </incGatewayRecord> <outGatewayRecord> <recordType>4</recordType> <callingNumber>A151012431</callingNumber> <calledNumber>817026936873</calledNumber> <recordingEntity>915212110100</recordingEntity> <mscIncomingROUTE> <rOUTEName>HWBSC</rOUTEName> </mscIncomingROUTE> <mscOutgoingROUTE> <rOUTEName>ZPSTN</rOUTEName> </mscOutgoingROUTE> <answerTime>0912021535192B0300</answerTime> <releaseTime>0912021535432B0300</releaseTime> <callDuration>24</callDuration> <causeForTerm>0</causeForTerm> <diagnostics> <gsm0408Cause>144</gsm0408Cause> </diagnostics> <callReference>2303B19880</callReference> <basicService> <teleservice>11</teleservice> </basicService> <additionalChgInfo> <chargeIndicator>2</chargeIndicator> </additionalChgInfo> <mscOutgoingCircuit>398</mscOutgoingCircuit> <orgMSCId>921A</orgMSCId> <mscOutgoingRouteAttribute> <isup/> </mscOutgoingRouteAttribute> <networkCallReference>238BE55132</networkCallReference> </outGatewayRecord> </callEventRecords> <trailerRecord> <productionDateTime>0912021247512B0300</productionDateTime> <recordingEntity>00</recordingEntity> <firstCallDateTime>000000000000000000</firstCallDateTime> <lastCallDateTime>000000000000000000</lastCallDateTime> <noOfRecords>521</noOfRecords> <extensions/> </trailerRecord> <extensions/> </CallEventDataFile> Schema File generated by Dataset: <?xml version="1.0" standalone="yes"?> <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="location"> <xs:complexType> <xs:sequence> <xs:element name="locationAreaCode" type="xs:string" minOccurs="0" /> <xs:element name="cellIdentifier" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="systemType"> <xs:complexType> <xs:sequence> <xs:element name="gERAN" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="basicService"> <xs:complexType> <xs:sequence> <xs:element name="teleservice" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="additionalChgInfo"> <xs:complexType> <xs:sequence> <xs:element name="chargeIndicator" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="chargedParty"> <xs:complexType> <xs:sequence> <xs:element name="calledParty" type="xs:string" minOccurs="0" /> <xs:element name="callingParty" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="mscIncomingROUTE"> <xs:complexType> <xs:sequence> <xs:element name="rOUTEName" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="mscOutgoingROUTE"> <xs:complexType> <xs:sequence> <xs:element name="rOUTEName" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="radioChanRequested"> <xs:complexType> <xs:sequence> <xs:element name="dualFullRatePreferred" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="radioChanUsed"> <xs:complexType> <xs:sequence> <xs:element name="halfRate" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="diagnostics"> <xs:complexType> <xs:sequence> <xs:element name="gsm0408Cause" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="CallEventDataFile"> <xs:complexType> <xs:sequence> <xs:element name="extensions" type="xs:string" minOccurs="0" /> <xs:element name="headerRecord" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="productionDateTime" type="xs:string" minOccurs="0" /> <xs:element name="recordingEntity" type="xs:string" minOccurs="0" /> <xs:element name="extensions" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="callEventRecords" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="mtSMSRecord" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="recordType" type="xs:string" minOccurs="0" /> <xs:element name="serviceCentre" type="xs:string" minOccurs="0" /> <xs:element name="servedIMSI" type="xs:string" minOccurs="0" /> <xs:element name="servedIMEI" type="xs:string" minOccurs="0" /> <xs:element name="servedMSISDN" type="xs:string" minOccurs="0" /> <xs:element name="msClassmark" type="xs:string" minOccurs="0" /> <xs:element name="recordingEntity" type="xs:string" minOccurs="0" /> <xs:element name="deliveryTime" type="xs:string" minOccurs="0" /> <xs:element name="orgRNCorBSCId" type="xs:string" minOccurs="0" /> <xs:element name="orgMSCId" type="xs:string" minOccurs="0" /> <xs:element name="globalAreaID" type="xs:string" minOccurs="0" /> <xs:element name="subscriberCategory" type="xs:string" minOccurs="0" /> <xs:element name="firstmccmnc" type="xs:string" minOccurs="0" /> <xs:element name="smsUserDataType" type="xs:string" minOccurs="0" /> <xs:element name="origination" type="xs:string" minOccurs="0" /> <xs:element name="callReference" type="xs:string" minOccurs="0" /> <xs:element ref="location" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="systemType" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="basicService" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="additionalChgInfo" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="chargedParty" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="moSMSRecord" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="recordType" type="xs:string" minOccurs="0" /> <xs:element name="servedIMSI" type="xs:string" minOccurs="0" /> <xs:element name="servedIMEI" type="xs:string" minOccurs="0" /> <xs:element name="servedMSISDN" type="xs:string" minOccurs="0" /> <xs:element name="msClassmark" type="xs:string" minOccurs="0" /> <xs:element name="serviceCentre" type="xs:string" minOccurs="0" /> <xs:element name="recordingEntity" type="xs:string" minOccurs="0" /> <xs:element name="messageReference" type="xs:string" minOccurs="0" /> <xs:element name="originationTime" type="xs:string" minOccurs="0" /> <xs:element name="destinationNumber" type="xs:string" minOccurs="0" /> <xs:element name="orgRNCorBSCId" type="xs:string" minOccurs="0" /> <xs:element name="orgMSCId" type="xs:string" minOccurs="0" /> <xs:element name="globalAreaID" type="xs:string" minOccurs="0" /> <xs:element name="subscriberCategory" type="xs:string" minOccurs="0" /> <xs:element name="firstmccmnc" type="xs:string" minOccurs="0" /> <xs:element name="smsUserDataType" type="xs:string" minOccurs="0" /> <xs:element name="callReference" type="xs:string" minOccurs="0" /> <xs:element ref="location" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="systemType" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="basicService" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="additionalChgInfo" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="chargedParty" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="ssActionRecord" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="recordType" type="xs:string" minOccurs="0" /> <xs:element name="servedIMSI" type="xs:string" minOccurs="0" /> <xs:element name="servedIMEI" type="xs:string" minOccurs="0" /> <xs:element name="servedMSISDN" type="xs:string" minOccurs="0" /> <xs:element name="msClassmark" type="xs:string" minOccurs="0" /> <xs:element name="recordingEntity" type="xs:string" minOccurs="0" /> <xs:element name="supplService" type="xs:string" minOccurs="0" /> <xs:element name="ssActionTime" type="xs:string" minOccurs="0" /> <xs:element name="callReference" type="xs:string" minOccurs="0" /> <xs:element name="ussdCodingScheme" type="xs:string" minOccurs="0" /> <xs:element name="ussdRequestCounter" type="xs:string" minOccurs="0" /> <xs:element name="orgRNCorBSCId" type="xs:string" minOccurs="0" /> <xs:element name="orgMSCId" type="xs:string" minOccurs="0" /> <xs:element name="globalAreaID" type="xs:string" minOccurs="0" /> <xs:element name="subscriberCategory" type="xs:string" minOccurs="0" /> <xs:element name="firstmccmnc" type="xs:string" minOccurs="0" /> <xs:element ref="location" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="ssAction" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="ussdInvocation" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="ssParameters" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="unstructuredData" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element ref="systemType" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="ussdString" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="UssdString" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element ref="additionalChgInfo" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="moCallRecord" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="recordType" type="xs:string" minOccurs="0" /> <xs:element name="servedIMSI" type="xs:string" minOccurs="0" /> <xs:element name="servedIMEI" type="xs:string" minOccurs="0" /> <xs:element name="servedMSISDN" type="xs:string" minOccurs="0" /> <xs:element name="callingNumber" type="xs:string" minOccurs="0" /> <xs:element name="calledNumber" type="xs:string" minOccurs="0" /> <xs:element name="roamingNumber" type="xs:string" minOccurs="0" /> <xs:element name="recordingEntity" type="xs:string" minOccurs="0" /> <xs:element name="msClassmark" type="xs:string" minOccurs="0" /> <xs:element name="answerTime" type="xs:string" minOccurs="0" /> <xs:element name="releaseTime" type="xs:string" minOccurs="0" /> <xs:element name="callDuration" type="xs:string" minOccurs="0" /> <xs:element name="causeForTerm" type="xs:string" minOccurs="0" /> <xs:element name="callReference" type="xs:string" minOccurs="0" /> <xs:element name="gsm-SCFAddress" type="xs:string" minOccurs="0" /> <xs:element name="serviceKey" type="xs:string" minOccurs="0" /> <xs:element name="networkCallReference" type="xs:string" minOccurs="0" /> <xs:element name="mSCAddress" type="xs:string" minOccurs="0" /> <xs:element name="speechVersionSupported" type="xs:string" minOccurs="0" /> <xs:element name="speechVersionUsed" type="xs:string" minOccurs="0" /> <xs:element name="numberOfDPEncountered" type="xs:string" minOccurs="0" /> <xs:element name="levelOfCAMELService" type="xs:string" minOccurs="0" /> <xs:element name="freeFormatData" type="xs:string" minOccurs="0" /> <xs:element name="classmark3" type="xs:string" minOccurs="0" /> <xs:element name="mscOutgoingCircuit" type="xs:string" minOccurs="0" /> <xs:element name="orgRNCorBSCId" type="xs:string" minOccurs="0" /> <xs:element name="orgMSCId" type="xs:string" minOccurs="0" /> <xs:element name="calledIMSI" type="xs:string" minOccurs="0" /> <xs:element name="globalAreaID" type="xs:string" minOccurs="0" /> <xs:element name="subscriberCategory" type="xs:string" minOccurs="0" /> <xs:element name="firstmccmnc" type="xs:string" minOccurs="0" /> <xs:element name="lastmccmnc" type="xs:string" minOccurs="0" /> <xs:element ref="mscIncomingROUTE" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="mscOutgoingROUTE" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="location" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="basicService" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="radioChanRequested" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="radioChanUsed" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="diagnostics" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="additionalChgInfo" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="systemType" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="chargedParty" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="mtCallRecord" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="recordType" type="xs:string" minOccurs="0" /> <xs:element name="servedIMSI" type="xs:string" minOccurs="0" /> <xs:element name="servedIMEI" type="xs:string" minOccurs="0" /> <xs:element name="servedMSISDN" type="xs:string" minOccurs="0" /> <xs:element name="callingNumber" type="xs:string" minOccurs="0" /> <xs:element name="recordingEntity" type="xs:string" minOccurs="0" /> <xs:element name="msClassmark" type="xs:string" minOccurs="0" /> <xs:element name="answerTime" type="xs:string" minOccurs="0" /> <xs:element name="releaseTime" type="xs:string" minOccurs="0" /> <xs:element name="callDuration" type="xs:string" minOccurs="0" /> <xs:element name="causeForTerm" type="xs:string" minOccurs="0" /> <xs:element name="callReference" type="xs:string" minOccurs="0" /> <xs:element name="networkCallReference" type="xs:string" minOccurs="0" /> <xs:element name="mSCAddress" type="xs:string" minOccurs="0" /> <xs:element name="speechVersionSupported" type="xs:string" minOccurs="0" /> <xs:element name="speechVersionUsed" type="xs:string" minOccurs="0" /> <xs:element name="classmark3" type="xs:string" minOccurs="0" /> <xs:element name="roamingNumber" type="xs:string" minOccurs="0" /> <xs:element name="mscIncomingCircuit" type="xs:string" minOccurs="0" /> <xs:element name="orgRNCorBSCId" type="xs:string" minOccurs="0" /> <xs:element name="orgMSCId" type="xs:string" minOccurs="0" /> <xs:element name="globalAreaID" type="xs:string" minOccurs="0" /> <xs:element name="subscriberCategory" type="xs:string" minOccurs="0" /> <xs:element name="firstmccmnc" type="xs:string" minOccurs="0" /> <xs:element name="lastmccmnc" type="xs:string" minOccurs="0" /> <xs:element ref="mscIncomingROUTE" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="mscOutgoingROUTE" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="location" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="basicService" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="supplServicesUsed" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="SuppServiceUsedid" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="ssCode" type="xs:string" minOccurs="0" /> <xs:element name="ssTime" type="xs:string" minOccurs="0" /> </xs:sequence>

    Read the article

  • How to restrict a content of string to less than 4MB and save that string in DB using C#

    - by Pranay B
    I'm working on a project where I need to get the Text data from pdf files and dump the whole text in a DB column. With the help of iTextsharp, I got the data and referred it String. But now I need to check whether the string exceeds the 4MB limit or not and if it is exceeding then accept the string data which is less than 4MB in size. This is my code: internal string ReadPdfFiles() { // variable to store file path string filePath = null; // open dialog box to select file OpenFileDialog file = new OpenFileDialog(); // dilog box title name file.Title = "Select Pdf File"; //files to be accepted by the user. file.Filter = "Pdf file (*.pdf)|*.pdf|All files (*.*)|*.*"; // set initial directory of computer system file.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); // set restore directory file.RestoreDirectory = true; // execute if block when dialog result box click ok button if (file.ShowDialog() == DialogResult.OK) { // store selected file path filePath = file.FileName.ToString(); } //file path /// use a string array and pass all the pdf for searching //String filePath = @"D:\Pranay\Documentation\Working on SSAS.pdf"; try { //creating an instance of PdfReader class using (PdfReader reader = new PdfReader(filePath)) { //creating an instance of StringBuilder class StringBuilder text = new StringBuilder(); //use loop to specify how many pages to read. //I started from 5th page as Piyush told for (int i = 5; i <= reader.NumberOfPages; i++) { //Read the pdf text.Append(PdfTextExtractor.GetTextFromPage(reader, i)); }//end of for(i) int k = 4096000; //Test whether the string exceeds the 4MB if (text.Length < k) { //return the string text1 = text.ToString(); } //end of if } //end of using } //end try catch (Exception ex) { MessageBox.Show(ex.Message, "Please Do select a pdf file!!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //end of catch return text1; } //end of ReadPdfFiles() method Do help me!

    Read the article

  • string comparision and counting the key in target [closed]

    - by mesun
    Suppose we want to count the number of times that a key string appears in a target string. We are going to create two different functions to accomplish this task: one iterative, and one recursive. For both functions, you can rely on Python's find function - you should read up on its specifications to see how to provide optional arguments to start the search for a match at a location other than the beginning of the string. For example, find("atgacatgcacaagtatgcat","atgc") #returns the value 5, while find("atgacatgcacaagtatgcat","atgc",6) #returns the value 15, meaning that by starting the search at index 6, #the next match is found at location 15. For the recursive version, you will want to think about how to use your function on a smaller version of the same problem (e.g., on a smaller target string) and then how to combine the result of that computation to solve the original problem. For example, given you can find the first instance of a key string in a target string, how would you combine that result with invocation of the same function on a smaller target string? You may find the string slicing operation useful in getting substrings of string.

    Read the article

  • Get context for search string in text in C#

    - by soundslike
    Given a string text which contains newline there is a search keyword which matches an item within the text. How do I implement the following in C#: searchIdx = search index (starting with 0, then 1, etc. for each successive call to GetSearchContext. Initially start with 0. contextsTxt = string data to search in searchTxt = keyword to search for in contextsTxt numLines = number of lines to return surrounding the searchTxt found (ie. 1 = the line the searchTxt is found on, 2 = the line the searchTxt is found on, 3 = the line above the searchTxt is found on, the line the searchTxt is found on, and the line below the searchTxt is found on) returns the "context" based on the parameters string GetSearchContext(int searchIdx, string contentsTxt, string searchTxt, int numLines); If there's a better function interface to accomplish this feel free to suggest that as well. I tried the following but doesn't seem to work properly all the time: private string GetSearchContext(string contentValue, string search, int numLines) { int searchIdx = contentValue.IndexOf(search); int startIdx = 0; int lastIdx = 0; while (startIdx != -1 && (startIdx = contentValue.IndexOf('\n', startIdx+1)) < searchIdx) { lastIdx = startIdx; } startIdx = lastIdx; if (startIdx < 0) startIdx = 0; int endIdx = searchIdx; int lineCnt = 0; while (endIdx != -1 && lineCnt++ < numLines) { endIdx = contentValue.IndexOf('\n', endIdx + 1); } if (endIdx == -1 || endIdx > contentValue.Length - 1) endIdx = contentValue.Length - 1; string lines = contentValue.Substring(startIdx, endIdx - startIdx + 1); if (lines[0] == '\n') lines = lines.Substring(1); if (lines[lines.Length - 1] == '\n') { lines = lines.Substring(0, lines.Length - 1); } if (lines[lines.Length - 1] == '\r') { lines = lines.Substring(0, lines.Length - 1); } return lines; }

    Read the article

  • String parsing help

    - by Click Upvote
    I have a string like the following: $string = " <paragraph>apples are red...</paragraph> <paragraph>john is a boy..</paragraph> <paragraph>this is dummy text......</paragraph> "; I would like to split this string into an array contanining the text found between the <paragraph></paragraph> tags. E.g something like this: $string = " <paragraph>apples are red...</paragraph> <paragraph>john is a boy..</paragraph> <paragraph>this is dummy text......</paragraph> "; $paragraphs = splitParagraphs($string); /* $paragraphs now contains: $paragraphs[0] = apples are red... $paragraphs[1] = john is a boy... $paragraphs[1] = this is dummy text... */ Any ideas? P.S it should be case insensitive, <paragraph>, <PARAGRAPH>, <Paragraph> should all be treated the same way.

    Read the article

  • java: decoding URI query string

    - by Jason S
    I need to decode a URI that contains a query string; expected input/output behavior is something like the following: abstract class URIParser { /** example input: * something?alias=pos&FirstName=Foo+A%26B%3DC&LastName=Bar */ URIParser(String input) { ... } /** should return "something" for the example input */ public String getPath(); /** should return a map * {alias: "pos", FirstName: "Foo+A&B=C", LastName: "Bar"} */ public Map<String,String> getQuery(); } I've tried using java.net.URI, but it seems to decode the query string so in the above example I'm left with "alias=pos&FirstName=Foo+A&B=C&LastName=Bar" so there is ambiguity whether a "&" is a query separator or is a character in a query component. edit: just tried URI.getRawQuery() and it doesn't do the encoding, so I can split the query string with a "&", but then what do I do? Any suggestions?

    Read the article

  • Java: Print and access List <String[]>

    - by battousai622
    Im reading in a file and storing it in t1. How do i access the elements in t1? When i try to print it i get addresses instead of values. Also whats the dif between string and string[]? CSVReader reader = new CSVReader(new FileReader("src/new_acquisitions.csv")); List <String[]> t1 = reader.readAll(); int i = 0 while(i < t1.size()) { System.out.println(t1.get(i)); i++; } output: [Ljava.lang.String;@9304b1 [Ljava.lang.String;@190d11 [Ljava.lang.String;@a90653 [Ljava.lang.String;@de6ced

    Read the article

  • Extracting a string starting with x and ending with y

    - by DMan
    First of all, I did a search on this and was able to find how to use something like String.Split() to extract the string based on a condition. I wasn't able to find however, how to extract it based on an ending condition as well. For example, I have a file with links to images: http://i594.photobucket.com/albums/tt27/34/444.jpghttp://i594.photobucket.com/albums/as/asfd/ghjk6.jpg You will notice that all the images start with http:// and end with .jpg. However, .jpg is succeeded by http:// without a space, making this a little more difficult. So basically I'm trying to find a way (Regex?) to extract a string from a string that starts with http:// and ends with .jpg

    Read the article

  • A regular expression that will allow a string with only one Capital Letter

    - by Phoenix
    The string should be 6 - 20 characters in length. And it should contain 1 Capital letter. I can do this in code using C# string st = "SomeString" Regex rg = new Regex("[A-Z]"); MatchCollection mc = rg.Matches(st); Console.WriteLine("Total Capital Letters: " + mc.Count); if (mc.Count > 1) { return false; } But what i really want is a Regular expression that will match my string if it only contains one capital. The string can start with a common letter and should have only letters. Thanks In advance. (I did look at some of the other RegEx questions but they did not help).

    Read the article

  • return new string vs .ToString()

    - by Leroy Jenkins
    Take the following code: public static string ReverseIt(string myString) { char[] foo = myString.ToCharArray(); Array.Reverse(foo); return new string(foo); } I understand that strings are immutable, but what I dont understand is why a new string needs to be called return new string(foo); instead of return foo.ToString(); I have to assume it has something to do with reassembling the CharArray (but thats just a guess). Whats the difference between the two and how do you know when to return a new string as opposed to returning a System.String that represents the current object?

    Read the article

  • C# - split String into smaller Strings by length variable

    - by tyndall
    I'd like to break apart a String by a certain length variable. It needs to bounds check so as not explode when the last section of string is not as long as or longer than the length. Looking for the most succinct (yet understandable) version. Example: string x = "AAABBBCC"; string[] arr = x.SplitByLength(3); // arr[0] -> "AAA"; // arr[1] -> "BBB"; // arr[2] -> "CC"

    Read the article

  • Speed vs security vs compatibility over methods to do string concatenation in Python

    - by Cawas
    Similar questions have been brought (good speed comparison there) on this same subject. Hopefully this question is different and updated to Python 2.6 and 3.0. So far I believe the faster and most compatible method (among different Python versions) is the plain simple + sign: text = "whatever" + " you " + SAY But I keep hearing and reading it's not secure and / or advisable. I'm not even sure how many methods are there to manipulate strings! I could count only about 4: There's interpolation and all its sub-options such as % and format and then there's the simple ones, join and +. Finally, the new approach to string formatting, which is with format, is certainly not good for backwards compatibility at same time making % not good for forward compatibility. But should it be used for every string manipulation, including every concatenation, whenever we restrict ourselves to 3.x only? Well, maybe this is more of a wiki than a question, but I do wish to have an answer on which is the proper usage of each string manipulation method. And which one could be generally used with each focus in mind (best all around for compatibility, for speed and for security). Thanks.

    Read the article

  • Formatting a string in Java using class attributes

    - by Jason R. Coombs
    I have a class with an attribute and getter method: public Class MyClass { private String myValue = "foo"; public String getMyValue(); } I would like to be able to use the value of foo in a formatted string as such: String someString = "Your value is {myValue}." String result = Formatter.format(someString, new MyClass()); // result is now "Your value is foo." That is, I would like to have some function like .format above which takes a format string specifying properties on some object, and an instance with those properties, and formats the string accordingly. Is it possible to do accomplish this feat in Java?

    Read the article

  • what's the C# equivalent of string$ from basic

    - by Preet Sangha
    And is there an elegant linqy way to do it? What I want to do is create string of given length with made of up multiples of another string up to that length So for length - 9 and input string "xxx" I get "xxxxxxxxx" (ie length 9) for a nun integral multiple then I'd like to truncate the line. I can do this using loops and a StringBuilder easily but I'm looking to see if the language can express this idea easily. (FYI I'm making easter maths homework for my son)

    Read the article

  • Application leaking Strings?

    - by Jörg B.
    My .net application does some heavy string loading/manipulation and unfortunately the memory consumption keeps rising and rising and when looking at it with a profiler I see alot of unreleased string instances. Now at one point of time or another I do need all objects t hat do have these string fields, but once done, I could get rid of e.g. the half of it and I Dispose() and set the instances to null, but the Garbage Collector does not to pick that up.. they remain in memory (even after half an hour after disposing etc). Now how do I get properly rid of unneeded strings/object instances in order to release them? They are nowhere referenced anymore (afaik) but e.g. aspose's memory profiler says their distance to the gc's root is '3'?

    Read the article

  • String manupulation classic interview questions

    - by user189364
    Hi, I am scheduled to have an onsite interview so I am preparing few basic questions. According to the company profile, they are big on string manipulation questions. So far i am manually coded these functions: 1) String length, copy, concat, remove white space 2) Reverse 3) Anagrams 4) Palindrome Please can some can give me a list of more classic string questions which i can practice before going there.

    Read the article

  • Can you reverse order a string in one line with LINQ or a LAMBDA expression

    - by Student for Life
    Not that I would want to use this practically (for many reasons) but out of strict curiousity I would like to know if there is a way to reverse order a string using LINQ and/or LAMBDA expressions in one line of code, without utilising any framework "Reverse" methods. e.g. string value = "reverse me"; string reversedValue = (....); and reversedValue will result in "em esrever" EDIT Clearly an impractical problem/solution I know this, so don't worry it's strictly a curiosity question around the LINQ/LAMBDA construct.

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >