I have a data set like the following, and the first column contains the groupings. However, some are labelled slightly differently. I need to remove all characters following the punctuation used (bracket, semicolon, comma). groups <- c("Group1", "Group1", "Group1;Group1", "Group1(subset)", "Group1,ex" ) I would like this to present all of these just as Group1 (so they would all appear the same as the first two) - so to remove all characters in the string following the punctuation. I then need …
I use a plugin for automatic posting of articles on social networks, and when I send an article on Facebook or Twitter from my website, the apostrophes of my articles are replaced by this: ' It is possible that the problem comes from the theme, but I am not sure. I tried to do a "search and replace" to replace this code with an apostrophe using a "regex" but it does not work at all
I have a custom post type called Hotels which I woud like to link to using the below url structure: /{country}/{state}/{hotel-name} I am fetching and inserting posts dynamically, so I do not know the number of countries/states. The Hotel Name is the slug version of the post title. I have been banging my head all day trying to get it to work. The below code works to make the links look correct, but then 404s on all posts: function change_link($permalink, …
So, basically, I want to remove trailing slashes from specific domain urls. For example: https://www.example.com/here/postname/ into https://www.example.com/here/postname I have 10.4.21-MariaDB which should support REGEXP_REPLACE function. This is my query: UPDATE wp_posts SET post_content = REGEXP_REPLACE(post_content, '(http\S+)\/(\s|$)', '$1'); or this one more specifically: UPDATE wp_posts SET post_content = REGEXP_REPLACE(post_content, '(https:\/\/www\.example\.com\/here\/\S+)\/(\s|$)', '$1'); which according to regular expressions should work: https://regex101.com/r/slLbgg/1 What am I doing wrong? Any kind of help is appreciated! :) This is the result:
I have a column named "MATCH" in a dataframe and a list of patterns named "PATTERN". df1.MATCH <- c("ABC", "abc" ,"BCD") df1 <- as.data.frame(df1.MATCH) df2.PATTERN <- c("ABC", "abc", "ABC abc") I want to use grepl to compare MATCH column with PATTERN, if true, I will apply my functions. The desired result would be "ABC" matches "ABC" and "ABC abc". This is the code I used: df1 %>% filter(grepl(df1.MATCH,df2.PATTERN ))%>% ... I get error: "Warning message: In grepl(TXN_GROUP, parm[3]) :argument 'pattern' …
We have been searching high an low for a plugin, code sample or example of how to remove all external links at the theme filter level but can't seem to find anything online. We want to keep the external links in the actual post database entry but simply remove them using add_filter() inside the theme's functions.php file so we can add them again when we need to. We would also need to filter out links for the domain the site …
I've seen similar questions posted before but they don't seem to quite fit my problem. I have a post type called product and I have 2 taxonomies, product_cat and location I want archive pages that combine both these taxonomies which would be structured like this /product/product_cat/location I know this can be done with rewrites but I can't figure out how to make it work. Update I've achieved this to an extent using add_rewrite_rule( '^art-classes/([^/]*)/([^/]*)/?', 'index.php?product_cat=$matches[1]&location=$matches[2]', 'top' ); But now my …
I'm using WPForms Pro and I'd like to add custom requirements to the password field on a form. I know that the password field has a password strength requirement setting, but I have specific rules I'd like to enforce, which are: Between 12 and 32 characters At least 1 number At least 1 capital letter At least 1 special character I came up with the following regex for this: ^(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{12,32}$ and wrote to WPForms support, who told me that they …
I'm about to start a part of my project that I've been putting off for too long. I'm not looking for code, I'm looking for confirmation that I'm on the right track and any advice Stackexchange may have to give on this subject. The setup: I have two different custom post types with two taxonomies, the first custom taxonomy, industries contains three terms for businesses to select, and the first custom post will be business-profiles. The second taxonomy departments will …
We have a site using WPML and the category archives like /categoryname/page/2 weren't working in the secondary language. I added /category/ to the permalink and now the pagination works, but I need help getting the paginated archive links to 301 redirect. I set up manual redirects for the main category archives using the Redirection plugin: Ex: /categoryname/ redirects to: /category/categoryname/ I need help with redirecting the paginated pages in the category archive. Ex: http://example.com/categoryname/page/1 redirects to http://example.com/category/categoryname/page/1 Single posts haven't …
found this neat code to highlight search terms. My problem with the code is that it does not prioritize exact matches and it highlights words within other words. So searching for "in my hometown" would also highlight "the tool was invented years ago". So two questions: How do I make sure that it only finds exact matches? How do I let the tool try to find and exact match first, and if not found try to find individual strings? Thanks …
I have text files which contains medical history of a patients and would want to extract information out of it. Basically what want is generate english text of abbrevations,semantic category region,location and relation also correct spelling mistakes if any by parsing medical history records. I have google around for open source tools and found cTAKES & Metamap.However could not find python api for the same. Can someone suggest how to make use of these tools or interact via python?and also …
I have some posts and some of them contain [gravityform] shortcode with different attribute values. Say, a post Hello World contains a shortcode [gravityform id="1" title="false" description="false"] Another post Hello Moon contains shortcode [gravityform description="true" id="23" title="true"] How can I get the value of id attribute of that shortcode programmatically?
The data is as follows: COL1 COL2 12 :402:agsh,hhjd,:45:hghgh,gruru,:12:fgh,ghgh,:22:hhhh 57 :42:agshhhjd,:57:hghgh,gruru,:120:fghghgh,:12:hhhhhh I am creating a third column field_info like: COL1 COL2 field_info 12 :402:agsh,hhjd,:45:hghghgruru,:12:fgh,ghgh,:22:hhhh fgh,ghg 57 :42:agshhhjd :57:hghgh,gruru:120:fghghgh :12:hhhhhh hghgh,g I am using a regex function as follows: df.loc[:,'field_info']=df.col2.replace(regex=r'.*'+ df.col1.astype('str') +':(.{15}).*',value="\\1") I have 2 columns col1 & col2. col1 has some value which I am searching in col2 dynamically and extracting the next 15 characters from that. However, it's taking a lot of time. Can anyone suggest a faster way …
I have an URL formatted so: http://domain.com/custom-post-type/category/cat-name/page/page-number I need to extract: cat-name and page-number So that in my functions.php, I can create the custom rewrite rule: function my_insert_rewrite_rules( $rules ) { $newrules = array(); $newrules['projects/category/(.+)/page/(\d+)/?$'] = 'index.php?post_type=project&project_cat=$matches[1]&paged=$matches[2]'; return $newrules + $rules; } I am trying to use the expression: projects/category/(.+)/page/(\d+)/?$ Which seems to work appropriately (escaping the forward slashes) in this example: http://rubular.com/r/5rzECsTexy However, this never seems to work, the URL: http://domain.com/projects/category/print and http://domain.com/projects/category/print/page/2 always seem to 404. My previous …
I do have an post/page where the shortcode "question" occurs many times. What is the best way to get an array of all the "question" shortcodes with their related parms? [question a=1 b=2 c=3 ] [question b=2 c=3 ] [question a=1 b=2 ] [question]
This relates to my previous question: Internal search spam (UPD: I no longer use Ivory Search) The closest question I found: Block search keywords As I understood, I need to use pre_get_posts, but I don't exactly know where it should go (functions.php?) and how I can create a regex-based rule to exclude everything that has "www." in it and non-Latin or non-numeric symbols like emojis and Cyrillic letters. I have the results noindexed and blocked in robots.txt, but I'd like …
I want to prevent users to write email addresses in comments. I know we can restrict words in wp-admin > Settings > Discussion > Disallowed Comment Keys. but can we add a RegExp such ([a-zA-Z0-9+._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+) to restrict all the emails? I was trying to add something like: //Regular expression to ban emails function te_check_comment($approved, $commentdata){ if(preg_match('#\b((?=[a-zA-Z0-9+._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+){1,5}\b#i',$commentdata["comment_content"])){ $approved = 0; } return $approved; } add_action('pre_comment_approved', 'te_check_comment', 10, 2); Source:https://techearl.com/wordpress/wordpress-moderate-comments-using-regular-expressions
Using add_rewrite_rule() to handle things like this for the custom post type "catalogs", page name "cars": /catalogs/cars/ /catalogs/cars/p1/ /catalogs/cars/p1/p2/ /catalogs/cars/p1/p2/p3/ I never have more than 3 parameters after /cars/, but all of them with optional query string parameters. Like this: /catalogs/cars/p1/p2/?weight-max=3200 Here's my code: add_rewrite_rule( '^catalogs/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?', 'index.php?catalogs=$matches[1]&p1=$matches[2]&p2=$matches[3]&p3=$matches[4]', 'top' ); Works great for when there's 3 parameters (like /catalogs/cars/p1/p2/p3/), but it doesn't work for when there's 0-2 parameters. Have tried making parts of the regex optional, but I guess my regex …
How to create validation in contact form 7 to prevent user input HTML tag like ... or , also to prevent scripts like $(dummy){}. I create validation to prevent URL and non Latin characters, how I can create for HTML tag or scripts? Here my code: function custom_text_validation_filter($result, $tag) { $type = $tag['type']; $name = $tag['name']; if($name == 'your-subject') { $value = $_POST[$name]; $nourl_pattern = '(http|https|href)'; $latin = "/^[a-zA-ZàèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇßØøÅåÆæœ\s\d.('\"£$%!&*()}{@#~><>|=_+^?\/\\;:,,.)]+$/"; if(preg_match($nourl_pattern,$value)){ $result->invalidate( $tag, "Subject cannot contain website addresses." ); } else …