What is the regex to strip the MY-CORP\ part of na inputed string like MY-CORP\My.Name with the java String.replaceAll method so I can get only the My.Name part?
I tried
public static String stripDomain(String userWithDomain) {
return userWithDomain.replaceAll("^.*\\", "");
}
but i got Unexpected internal error near index 4 ^.*
...
I need two functions that would take a string and return if it starts with the specified character/string or ends with it.
For example:
$str='|apples}';
echo startsWith($str,'|'); //Returns true
echo endsWith($str,'}'); //Returns true
...
I need 2 functions that take a string and the number of chars to trim from the right and left side and return it. E.g:
$str = "[test]";
$str = ltrim($str,1); //becomes test]
$str = rtrim($str,1); //becomes test
Thoughts?
...
I need to hold a representation of a document in memory, and am looking for the most efficient way to do this.
Assumptions
The documents can be pretty large, up
to 100MB.
More often than not the document
will remain unchanged - (i.e. I don't
want to do unnecessary up front
processing).
Changes will typically be quite close
to each oth...
I'd like a regexp or other string which can replace everything except alphanumeric chars (a-z and 0-9) from a string. All things such as ,@#$(@*810 should be stripped. Any ideas?
Edit: I now need this to strip everything but allow dots, so everything but a-z, 1-9, .. Ideas?
...
Is there a more elegant way to structure the following code, which takes a comma delimited string containing certain values in specific positions and assigns the values to the properties of an object?
// split comma delimited items into a string array
Dim items As String() = myList.Split(CChar(","))
// Assign my...
Hi,
how can I convert this string:
bKk_035A_paint-House_V003
to
BKK_035a_paint-House_v003
with a regular expression (e.g. Regex.Replace)?
This regex matches the string:
^(?<Group1>[a-z][a-z0-9]{1,2})_(?<Group2>\d{3}[a-z]{0,2})_(?<Group3>[a-z-]+)_(?<Group4>v\d{3,5})$
Group1 = uppercase
Group2 = lowercase
Group3 = unchanged ...
The CFStringTokenizer documentation has two conflicting statements in CFStringTokenizerAdvanceToNextToken():
CFStringTokenizerAdvanceToNextToken
...
Return Value
The type of the token if the tokenizer succeeded in finding a token and setting it as current token. Returns kCFStringTokenizerTokenNone if the tokenizer fail...
I want an algorithm which would create all possible phrases in a block of text. For example, in the text:
"My username is click upvote. I have 4k rep on stackoverflow"
It would create the following combinations:
"My username"
"My Username is"
"username is click"
"is click"
"is click upvote"
"click upvote"
"i have"
"i have 4k"
"have 4...
Can someone explain why I get different results from these two statements? I thought that reassigning the value to the same variable would result in the value I get in the above example. What am I missing here?
_body.Replace("##" + _variableName + "##",
templateVariables[_variableName])
Hello pitty ##LastName##,
_body = _body.Rep...
Let's say I have an array of strings:
string[] myStrings = new string[] { "First", "Second", "Third" };
I want to concatenate them so the output is:
First Second Third
I know I can concatenate them like this, but there'll be no space in between:
string output = String.Concat(myStrings.ToArray());
I can obviously do this in a loo...
How would I perform the following in JQuery?
var elmOperator = document.getElementById(elm.id.replace('Include', 'Operator'));
The ID that is being manipulated would look something like Criteria[0].Include. I am trying to create a variable for a related ID which is Criteria[0].Operator.
Thanks in advance!
...
I was wondering what the best way to format a string would be in Scala. I'm reimplementing the toString method for a class, and it's a rather long and complex string. I thought about using String.format but it seems to have problems with Scala. Is there a native Scala function for doing this?
...
I'm looking for one regular expression that could match a string for three specific cases in a xml file:
: Double-quotes surrounding a string.
: A string surrounded by the characters greater than and Less Than.
: A string surrounded by the characters ; and &.
Example:
"MyString" - Valid match
>MyString< - Valid match
;MyString - I...
File files[] = rootDir.listFiles(new FileFilter() {
public boolean accept(File file) {
if (file.isDirectory())
return true;
String name = file.getName().toLowerCase();
if (name.endsWith(".zip") || name.endsWith(".jar")
|| name.endsWith(".z") || name.endsWith(".gz")
|| name.endsWith(".tar") || n...
This seems to be a very odd problem that I cannot figure out for the life of me. I have a path (string) that looks like this:
D:\development\php\bchat\chat\index.php
I need to check if the file in question is a PHP file. I figure the most logical way is to take a substring starting from the . to the end of the string and see if it ...
I'm creating a function which can accept a string which is either retrieved through file_get_contents() on a local text file, or something fetched from a url such as http://site.com/338383.txt.
The file will be a tab seperated file, with each item in the file being on its own line. Is it better to use \n or \r to explode() the string an...
Guys how do I remove the carriage return character(\r) and the new line character(\n) from the end of a string?
...
Hi,
I have a string like this:
String A: [ 12234_1_Hello'World_34433_22acb_4554344_accCC44 ]
I would like to encrypt String A to be used in a clean URL. something like this:
String B: [ cYdfkeYss4543423sdfHsaaZ ]
Is there a encode API in python, given String A, it returns String B?
Is there a decode API in python, given String B,...
Some fancy websites show an error dialog when it is detected that an untrained shopper has entered a credit/debit card number as it is printed on their card with spaces. Is it possible in some way to write a Java web app that handles these numbers with spaces as if they were correct?
...