Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a class library to add a customized toolbox to a external IE browser.
I'm using SHDocVw to do the back/forward buttons (e. g.). My question is, sense this is multilingual, how can I change the buttons text...
The url give me "/en/" or "/ar/", how can i catch this?
Thanks
With the Mati Cicero answer I managed to do it.
string page = ie.LocationURL;
Regex rgx = new Regex(#"https?://[a-zA-Z0-9.-_]+(/((?'lang'ar|en)|.*))/?");
var lang = rgx.Match(page).Success ? rgx.Match(page).Groups[1].Value : "ar";
You can try the following regex, I tried to make it as much generic as I could:
https?:\/\/[a-zA-Z0-9\.\-_]+(\/((?'lang'es|en)|.*))\/?
You would then examine the group "lang" to see if a match was made.
You would aso like to add more available languages (Added ch and in):
https?:\/\/[a-zA-Z0-9\.\-_]+(\/((?'lang'es|en|ch|in)|.*))\/?
If its always the first directory;
var lang = new Uri("http://sitename.com/en/pages/default.aspx")
.Segments[1].Replace("/", string.Empty).ToLower();
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 5 years ago.
Improve this question
I need to get diagram`s name of specific elements. Is it possible ?
I added elements note with specific stereotypu using profile to EA project. Then i want create a plugin where i find this notes and diagram names where they are located. (i want export notes and diagram names to excel)....PS: Sorry for my bad english
Issue a SQL like
Repository.SQLQuery("SELECT t_diagram.name FROM t_diagramobjects AS dobj INNER JOIN t_diagram ON dobj.diagram_id = t_diagram.diagram_id WHERE t_diagramobjects.Object_ID = <elementID>"
Just replace <elementID> with the element's elementID. You could alternatively retrieve the diagram GUID (t_diagram.ea_guid') and get the diagram details viaRepostory.GetDiagramByGUID`.
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 made replace function, but I am really struggling to make "Replace All"
function.
I tried to make into for loop but that didn't work well...
I have dialog box just like in usual Notepad (another form) and i have richtextbox in Main form. Any ideas how can I make it?
You can simply use the String.Replace method:
private void DoReplace(string SearchFor, string ReplaceWith)
{
RichTextBox1.Text = RichTextBox1.Text.Replace(SearchFor, ReplaceWith);
}
Call this function and supply the string you want to search for in Richtextbox1 (or whatever it is called in your case) as the first parameter and the replacement as the second parameter.
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
How can I extract the word "Word" (or any word) using Regex into a string in both cases? in the following string:
Word = CreateObject(980, -1696.5996, -12.2998, 5.3, 0, 0, 317.999);
MoveObject(Word, -1660.9004, 79.40039, 2.2,6);
I am pretty new in Regex, and I am having hard time understanding the tutorials over the internet.
I have tried using /(.*)( = CreateObject)/ but no luck
Tried using /MoveObject\(.*?\,/ and it works, but it matches MoveObject too, and I want it to match only "Word"
Thanks!
You could try the below regex.
#".*?(?= = CreateObject)|(?<=MoveObject\().*?(?=,)"
OR
#"\S+?(?= = CreateObject)|(?<=MoveObject\().*?(?=,)"
DEMO
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a large text. I need find any word in the text then copy to variable the phrase that contains the word. How can I do this by C#? Maybe I can use some regular expression?
Use the regex expression [^.!?;]*(search)[^.?!;]*[.?!;], where "search" is your query.
string query = "professional";
var regex = new Regex(string.Format("[^.!?;]*({0})[^.?!;]*[.?!;]", query));
string text =
#"Stack Overflow is a question and answer site for professional and enthusiast programmers.
It's built and run by you as part of the Stack Exchange network of Q&A sites.
With your help, we're working together to build a library of detailed answers to
every question about programming.";
var results = regex.Matches(text);
for (int i = 0; i < results.Count; i++)
Console.WriteLine(results[i].Value.Trim());
This code uses the regex to find all sentences containing "professional", and outputs them, trimming any whitespace.
Output: Stack Overflow is a question and answer site for professional and enthusiast programmers.
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 a URL, such as http://www.mydomain.com/?param1=asd2¶m2=asd2.
I'd like to create a sort of Frequest object, so than I can easily do somethings like:
Request.Querystring("param1")
without do a further Split and access to the array. Can I?
Your question is not clear. Are you looking something like this?
var uri = new Uri("http://www.mydomain.com/?param1=asd2¶m2=asd2");
var nv = uri.ParseQueryString();
Console.WriteLine(nv["param1"]);
EDIT
It seams one of my referenced libraries implemented this extension Method. Anyway, it can be done as
var uri = new Uri("http://www.mydomain.com/?param1=asd2¶m2=asd2");
var nv = HttpUtility.ParseQueryString(uri.Query);
Console.WriteLine(nv["param1"]);