string-manipulation

Deleting particular text in a file using c#?

Hi Friends, My text file named test.txt contains Fixing the type manager error during checkin of the elements and supporting issues during Checkin/Checkout & merge related problems. Now i want to remove the text "supporting issues" using c#. Please anybody let me know. Thanks in advance, Naveenkumar.T ...

COBOL alternative to BASIC's MID and how to concat strings?

Hi, I'm looking for the COBOL alternative of Visual Basic's MID Function. The thing I need to do is take from 8 strings the first 5 letters and concatenate them. I'm using Fujitsu COBOL. Many thanks, Yvan ...

How can I modify strings using a "For Each" loop?

'Why doesn't this work? Dim myStrings As String() = New String() {string1, string2, string3,} For Each s As String In myStrings If String.IsNullOrEmpty(s) Then s = "" End If s = "-" & s.Trim() & "-" Next If string1 contains "foo", my intention is that string1 contains "-foo-" aft...

How can I enable a word-breaking function by length without split inside html-encoded special chars.

I would like to implement a functionality that insert a word-breaking TAG if a word is too long to appear in a single line. protected string InstertWBRTags(string text, int interval) { if (String.IsNullOrEmpty(text) || interval < 1 || text.Length < interval) { return text; } int pS = 0, pE = 0, tLength = te...

spliting a string in Javascript

I am trying to extract an article ID from the following href: /MarketUpdate/Pricing/9352730 I just want to extract the ID at the end of the string and am using the following code: var $newsLink = $(this).attr('href'); var $newsString = $newsLink.substr($newsLink.lastIndexOf('/')); However this returns the final '/' which i...

I need help splitting addresses (number, addition, etc)

Hi! Apologies for the fuzzy title... My problem is this; I have a SQL Server table persons with about 100.000 records. Every person has an address, something like "Nieuwe Prinsengracht 12 - III". The customer now wants to separate the street from the number and addition (so each address becomes two or three fields). The problem is tha...

Regular Expression Help - String - JWE-766.1.pdf - Pattern - Extract 766

Hi all, I would like some help with a regular expression. I have some files like this: JWE-766.1.pdf JWE-766.2.pdf JWE-768.1.pdf JWE-770.1.pdf I would like a regex pattern to extract the number after 'JWE-'. i.e. 766. Also, a regex expression to extract 1 and 2 from JWE-766.1.pdf and JWE-766.2.pdf respectively. Any help would be ...

how do I convert a string to a valid variable name in python ?

Python n00b here I need to convert an arbitrary string to a string that is a valid variable name in python. Here's a very basic example: s1 = 'name/with/slashes' s2 = 'name ' def clean(s): s = s.replace('/','') s = s.strip() return s print clean(s1)+'_'#the _ is there so I can see the end of the string That is a very n...

substring match faster with regular expression?

Hello, After having read up on RE/NFA and DFA, it seems that finding a substring within a string might actually be asymptotically faster using an RE rather than a brute force O(mn) find. My reasoning is that a DFA would actually maintain state and avoid processing each character in the "haystack" more than once. Hence, searches in long...

Regex to remove all special characters from string?

I'm completely incapable of regular expressions, and so I need some help with a problem that I think would best be solved by using regular expressions. I have list of strings in C#: List<string> lstNames = new List<string>(); lstNames.add("TRA-94:23"); lstNames.add("TRA-42:101"); lstNames.add("TRA-109:AD"); foreach (string n in lstNam...

How to manipulate string in an array

I have an array that contain some fields like this ctl00_ctl00_cphBody_bodycph_content_rdo_SID_25_SortOrder_17 ctl00_ctl00_cphBody_bodycph_content_rdo_SID_25_SortOrder_18 ctl00_ctl00_cphBody_bodycph_content_rdo_SID_25_SortOrder_19 I want to create a new array or manipulate this array to contain only sid = {25,26,27} from _SID_25 ...

How can I limit a string if it's larger than desired?

I currently have a string that I want to limit to 200 characters. I don't know how to format it so if it's less, it wont change, but if its more, it will trim it. This is in a ListView Control, NOT a Repeater. Sorry for that, my mistake. <ItemTemplate> <div class="portfolio_title"> <div class="custom_title"> <%# DataBinder.Eval(Contai...

String Formating in C#

I have a list of strings like A_1 A_2 A_B_1 X_a_Z_14 i need to remove the last underscore and the following characters. so the resulting list will be like A A A_B X_a_Z please post a way to do this Thanks in advance ...

How to delete a line having line number using c#?

Hi Friends, My file named as test.txt contains This document is divided into about 5 logical sections starting with a feature and structure overview, followed by an overview of built in column and cell types. Next is an overview of working with data, followed by an overview of specific major features. Lastly, a “best practice” section ...

Replacing a specific part of a query string PHP

I use $_SERVER['QUERY_STRING'] to get the query sting. A example would be a=123&b=456&c=789 How could I remove the b value from the query string to obtain a=123&c=789 where b can be any value of any length and is alpha numeric. Any ideas appreciated, thanks. ...

Need to insert - into a variable holding a date?

I have a date variable with the format 2008 12 29 to have it correctly display from within my database app I need the format to be 2008-12-29 Is there a way to simply add the - into the string or replace the spaces with -? I am using PHP and the date is stored in $release_date ...

Cleaner way to convert from CStringW to std::string?

I figured out a somewhat convoluted way to convert a CStringW to a std::string, but I was wondering if there's a cleaner way than: CStringW cwstr; std::wstring stdwstr = cwstr; std::string stdstr = CW2T(stdwstr.c_str()); ...

Remove Last Path Component In a String

I have a path: myPath = "C:\Users\myFile.txt" I would like to remove the end path so that the string only contains: "C:\Users" So far I am using split, but it just gives me a list, and im stuck at this point. myPath = myPath.split(os.sep) Thanks ...

Extracting number ID from a URL in Javascript

Similar to my previous question: http://stackoverflow.com/questions/3300433/spliting-a-string-in-javascript The URLs have now changed and the unique number ID is no longer at the end of the URL like so: /MarketUpdate/Pricing/9352730/Report How would i extract the number from this now i cannot use the previous solution? ...

PHP String Function

Simply put, I have a string with a prefix "msg" followed by some numbers that serve as the ID for a list item e.g. <li id="msg1"></li>..............<li id="msg1234567890"></li> What is the most efficient way to grab just the numbers? In VB, I'd do the following: str = "msg1" str = right(str,len(str)-3) How would I do something ...