[Solved] Remove the end of a string with a varying string length using PHP

[ad_1] You can use a regex like this: -\d+x\d+(\.\w+)$ Working demo The code you can use is: $re = “/-\\d+x\\d+(\\.\\w+)$/”; $str = “http://website.dev/2014/05/my-file-name-here-710×557.png”; $subst=”\1″; $result = preg_replace($re, $subst, $str, 1); The idea is to match the resolution -NumbersXNumbers using -\d+x\d+ (that we’ll get rid of it) and then capture the file extension by using (\.\w+)$ … Read more

[Solved] C# if then else issues [closed]

[ad_1] Your braces and try{} catch{} blocks are mismatched. Here is the corrected code: public partial class frmPersonnel : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { try { DateTime dt1; DateTime dt2; if (txtFirstName.Text == “”) { txtFirstName.BackColor = System.Drawing.Color.Yellow; lblError.Text = “Please enter first … Read more

[Solved] How can I use a class from a header file in a source file using extern but not #include?

[ad_1] Just to clarify. It is impossible to extern the class: class Outside { public: Outside(int count); GetCount(); } But, once you have the class available in framework.cpp, you CAN extern an object of type Outside. You’ll need a .cpp file declaring that variable: #include “outside.h” Outside outside(5); And then you can refer to that … Read more

[Solved] What is the difference between assigning a pointer to variable address and explicitly to memory address?

[ad_1] Those are both undefined behavior. You are trying to modify memory that you did not allocate. The second is even less safe, because you are assuming a is going to be allocated to that address every time, which is absolutely not a safe assumption. 3 [ad_2] solved What is the difference between assigning a … Read more

[Solved] Replace multiple substrings between delimiters in Java

[ad_1] From comment: but if I do not know the text between the delimiters? So it sounds like the replacement values are positional. Best way to do this is a regular expression appendReplacement loop: public static String replace(String input, String… values) { StringBuffer buf = new StringBuffer(); Matcher m = Pattern.compile(“\\|{2}(.*?)\\|{2}”).matcher(input); for (int i = … Read more

[Solved] Unordered Random Numbers [closed]

[ad_1] if you want to generate random numbers in range without repeating, you can try this: public static List<int> GenerateNumbers(int mn,int mx) { List<int> source = new List<int>(); for (int i = mn; i <= mx; i++) source.Add(i); var random = new Random(); List<int> randomNumbers = new List<int>(); while(source.Count != 0) { int randomIndex = … Read more