replace

Insert a Newline Character using Regex Replace

。_饼干妹妹 提交于 2019-12-25 18:40:55
问题 I am trying to insert a newline character using a regex replace like so: strFile = Regex.Replace( strFile, @"(FA|BO)\s+(\d{3}-\d+)(\s+)(.*?)(\s+)(\d+,*\d*\.\d+)\s*(FA|BO)\s+(\d{3}-\d+)(\s+)(.*?)(\s+)(\d+,*\d*\.\d+)\s*", @"$2&$4&$6\n$8&$10&$12" ) but I end up with (literally) word\nword rather than an actual newline. What am I doing wrong? 回答1: By using the @"" string literal for the replacement string, you're disabling the escape character parsing. If you make the change to the second string

Batch Script - Find and replace text in multiple files in a directory without asking user to install any program or add other files to my batch script

喜欢而已 提交于 2019-12-25 18:16:31
问题 I need batch file that searches for a text (eg., FOO) and replaces it with another text (eg., BAR) in all the text files within a folder and it's sub-folders. I need to give this batch file to the user. So, it is not possible to ask the user to install anything else and also i don't wanna add other files to my batch script, is that even passable? I found many answer for this issue but everyone advise to install other program or to add a file to the batch script . Can someone please help me

Match newlines in non empty lines and not preceded by some characters

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 17:08:19
问题 I tried to use the regexp (?<=^(?![ \t]*@).+)(?<![\{\};:)]|//.{0,1024}|^[ \t]+)\R to: Match newlines without matching preceding characters Don't match newlines in only-space lines (empty lines) Don't match newlines in lines started by optional spaces (not newlines) and at-symbol '@'. Don't match newlines in lines containing [unescaped] '//'. Don't match newlines preceded by '{', '}', ';' or ':'. (better if doesn't match newlines preceded by optional spaces and that characters.) That regexp

Vue Router 编程式的导航

谁都会走 提交于 2019-12-25 13:20:23
除了使用 <router-link > 创建 a 标签来定义导航链接,我们还可以借助 router 的实例方法,通过编写代码来实现。 router.push(location, onComplete?, onAbort?) 注意:在 Vue 实例内部,你可以通过 r o u t e r 访 问 路 由 实 例 。 因 此 你 可 以 调 用 t h i s . router 访问路由实例。因此你可以调用 this. r o u t e r 访 问 路 由 实 例 。 因 此 你 可 以 调 用 t h i s . router.push。 想要导航到不同的 URL,则使用 router.push 方法。这个方法会向 history 栈添加一个新的记录,所以,当用户点击浏览器后退按钮时,则回到之前的 URL。 当你点击 <router-link > 时,这个方法会在内部调用,所以说,点击 <router-link :to="…"> 等同于调用 router.push(…)。 声明式 编程式 <router-link :to="…"> router.push(…) 该方法的参数可以是一个字符串路径,或者一个描述地址的对象。例如: // 字符串 router.push('home') // 对象 router.push({ path: 'home' }) // 命名的路由 router

Replacing words with greek letters in SublimeText

无人久伴 提交于 2019-12-25 10:53:12
问题 I'm trying to create a snippet in SublimeText which replaces words I type with greek letters after pressing ctrl+g. e.g.: sigma -> ctrl+g -> σ I could make a snippet for each letter, but I have the feeling it should be easier. I don't want to scan through the whole document, only the word the cursor is currently at. 回答1: I was looking for a similar thing and just stumbled over the Package "Greek Letters" by Arne Ludwig (for ST2/ST3): https://packagecontrol.io/packages/Greek%20Letters It works

Replacing words with greek letters in SublimeText

空扰寡人 提交于 2019-12-25 10:53:08
问题 I'm trying to create a snippet in SublimeText which replaces words I type with greek letters after pressing ctrl+g. e.g.: sigma -> ctrl+g -> σ I could make a snippet for each letter, but I have the feeling it should be easier. I don't want to scan through the whole document, only the word the cursor is currently at. 回答1: I was looking for a similar thing and just stumbled over the Package "Greek Letters" by Arne Ludwig (for ST2/ST3): https://packagecontrol.io/packages/Greek%20Letters It works

Replace a string with a user control

允我心安 提交于 2019-12-25 10:35:24
问题 How can I replace a string with UserControl? if string = [$control1$] replace with control1.ascx 回答1: You can't set a string to a control, as they are completely different types. You can set a string to the text of a control, as the text is of type string: string myString = control.Text; 回答2: Do you mean the HTML output by the user control if it is loaded into a page? Try this: using System.Web.UI; public static string RenderToString(this Control control) { var sb = new StringBuilder(); using

How to find and replace a particular unicode character with a non-unicode character in an NSString?

杀马特。学长 韩版系。学妹 提交于 2019-12-25 10:01:25
问题 I am being provided a string that may have a unicode apostrophe in it (\u2019) and I must replace it with a standard apostrophe (plain old "'"). I usually use stringByReplacingOccurrencesOfString to do this kind of thing but trying this does not work: sMyString = [sMyString stringByReplacingOccurrencesOfString:@"\\u2019" withString:@"'"]; Makes sense that it didn't work I guess since the actual values representing the apostrophe internally in the NSString will be numeric. Anyone know how to

How to use just asterisk wildcard when searching?

时间秒杀一切 提交于 2019-12-25 09:17:04
问题 I want to just support asterisk(*) wildcard not regex. This is my code : for example : checkNames[i] = "Number of ongoing MS sessions" var checkName = checkNames[i].split("*").join(".*"); supportRegExp(dataSource[j].ColumnName, checkName, validatedList,dataSource[j]); and this is my supportRegExp function : function supportRegExp(arrayElem, checkName, validatedList, elem) { var regexpArr = checkName .replace(/\t/g, '\n') .split("\n") .map(function (item) { return "^" + item + "$"; }); var

sed replace number with number-1

有些话、适合烂在心里 提交于 2019-12-25 09:12:04
问题 Can sed handle a substitution and simultaneously evaluate an expression to substitute somehow? For example, I have the following entry in a text file: ##################################### topd Tree1 - Tree14 ####################################### For reasons I won't go in to, each Tree's number is N+1 relative to another numbering scheme I've been using so far. Could sed (or any util really, sed is just my go to for find-and-replace operations), find every instance of TreeN and replace them