Finding last characters with grep
I am lousy with grep and didn't find the solution with google, so let's ask here (help me out, please...)
I need to find last 7 characters of a paragraph and assign a character style "no break" to it. I know everything else, but what's the string to find the 7 last characters (incl. white spaces, digits and letters).
Thanks in advance.
try searching for .{7}$
Similar Messages
-
Find/Change words (with GREP) and apply a style...
I need a Script for Find/Change words with GREP, and apply a paragraph style...
Thanks...Hi Marcos,
If you want the script to create character styles: Bold , Italic, Bold Italic, etc, and replace local formatting with these styles, use scripts in post #3.
But if you want find and change words, or/and replace local formatting with styles defined by you, use FindChangeByList script.
If the latter, I recommend you to download and install Record Find Change script (written by Martin Fisher).
Then choose settings you need in Find-Change dialog – make sure they work as expected – and run Record Find Change script. A Notepad/TextEdit file will pop up with a line containing the recorded setting. Copy it, open FindChangeList.txt, delete the contents of this file and paste the line you just copied (or add it to the bottom of the file).
Repeat the process for all find-change operations you need.
Finally run FindChangeByList.jsx to make all changes in one go.
However, while using Record Find Change script, you may encounter a problem: it doesn’t record paragraph and character styles placed inside a group. But you can write references to such styles like so:
appliedParagraphStyle:app.activeDocument.paragraphStyleGroups.item("Style Group 1"). paragraphStyles.item("Paragraph Style 1")
Kasyan -
Finding multiple characters with IndexOf.
I was wondering how I could find mutiple characters in a String using IndexOf, or anything else that might work.
An example would be wanting to find the first position of any vowel.
thanks in advance.ok, heres some code. The whole point of this method is find the first occurence of a,e,i,o, or u. The greater cause is a PigLatin translator.
public static String findFirstVowel(String input)
int word;
word = input.indexOf('a'); //this is where I think the problem lies
if(word > 0)
System.out.println(word) //just for debugging purposes
return word + "";
return "";
}//findFirstVowel() -
How To Find Last Row With Data +2, Then Format?
I need to find the last row +2, select the range A:L, then format.
Could someone please supply the code? I can handle the format part.
Thanks!
A. WolfWorks great!
I need to do 2 other things:
1) Add a text value to r in A: & center over selection A:L
Dim r As Long
r = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
USED THIS BUT ENDING UP IN MIDDLE OF L:!
ActiveCell = Range("A" & r)
ActiveCell.Value = "Estimated True Up Total"
2) 2) Format a total in r as currency/2 decimels/aligned to right.
THANKS AGAIN!!!
A. Wolf -
With GREP, is there a way to assign a character find/change to a p style?
I'm looking for more ways to automate text styling in the magazine I produce. In InDesign, I can assign find/replace command strings in the Find/Change GREP window, but I've found no online source that tells me how to find/replace characters using GREP WITHIN a p style. It seems as if the latter GREP capability is limited to changing character styles and can't search and replace actual characters.
Example: I have a list of recipe ingredients. I want to replace the quantity (one to three digits) at the beginning of each ingredient with a tab-digit(s)-tab combination. In Find/Change, I can enter "\d+\s" and replace with "\t$0\t" but I don't see a way to assign that capability to a p style. I want this find/change to occur automatically any time copy is added to text tagged with the Recipe Ingredients paragraph style, so I don't have to keep running a Find/Change each time we edit the page. One power user has told me it's not possible. Any insight or alternative solution would be much appreciated.Your power source has it right, GREP Styles can only apply character styles to the text it finds.
And there is no easy way to have text replaced automatically -- you would still need to run a script, or press a hotkey or something. -
Query to find vendor number with whom a particular item was last purchased.
Hi All,
I want to frame a SQL query to find vendor number with whom a particular item was last purchased.
I got to know that we can find this by looking at the open Purchase Order or the Material Transactions for the transaction type of ‘PO Receipt’ whichever is the latest.
Can anyone please help me in framing such query.
Regards,
ShrutiHere is a hint
Use the mtl_system_items_b table to get the inventory_item_id.
Use it in the po_lines_all table to get po_header_id
Use it in po_headers_all table to get vendor_id
Use it in po_vendors to get segment1 (i.e. vendor#)
Hope this helps,
Sandeep Gandhi -
Finding undisplayable characters in a field with a WHERE clause
Oracle_Rdb7 for_OpenVMS Release 7.0.1. I have a field in my table that has been loaded with data that contains "return/line feed" characters (I'm not sure of the ASCII hex representation) which can't be displayed and show up as "." on my screen. How can I code a WHERE clause that will find these characters, e.g., SELECT * FROM TABLE1 WHERE NAME CONTAINING <here is where I want to put the ASCII hex value for a "return/line feed" character>? Also, how could I get the actual ASCII hex code for these characters to display, e.g., "31" instead of "1"?
a 'return' is CHR(10) So you can:
select * from my_table where text_fld like '%'||CHR(10)||'%' -
I purchased an ipad for my husband in 12/2011 - it was stolen last night and i can't find the receipt with insurance and warranty.
The warraty doesn't cover lost or stolen.
If the iPad was running iOS 7, the thief/finder will not ever be able to use it.
iCloud: Find My iPhone Activation Lock in iOS 7
http://support.apple.com/kb/HT5818
Apple (and no one else) can not assist (with serial number or iCloud) in finding a lost or stolen iPad.
Report to police along with serial number. Change all your passwords.
These links may be helpful.
How to Track and Report Stolen iPad
http://www.ipadastic.com/tutorials/how-to-track-and-report-stolen-ipadhttp://www.ipadastic.com/tutorials/how-to-track-and-report-stolen-ipad
Reporting a lost or stolen Apple product
http://support.apple.com/kb/ht2526
What to do if your iOS device is lost or stolen
http://support.apple.com/kb/HT5668
iCloud: Locate your device on a map
http://support.apple.com/kb/PH2698
iCloud: Lost Mode - Lock and Trace
http://support.apple.com/kb/PH2700
iCloud: Remotely Erase your device
http://support.apple.com/kb/PH2701
Report Stolen iPad Tips and iPad Theft Prevention
http://www.stolen-property.com/report-stolen-ipad.phphttp://www.stolen-property.com/report-stolen-ipad.php
How to recover a lost or stolen iPad
http://ipadhelp.com/ipad-help/how-to-recover-a-lost-or-stolen-ipad/
How to Find a Stolen iPad
http://www.ehow.com/how_7586429_stolen-ipad.htmlhttp://www.ehow.com/how_7586429_stolen-ipad.html
What NOT to do if your iPhone or iPad is lost or stolen
http://www.tomahaiku.com/what-not-to-do-if-your-iphone-or-ipad-lost-or-stolen/http://www.tomahaiku.com/what-not-to-do-if-your-iphone-or-ipad-lost-or-stolen/
Apple Product Lost or Stolen
http://sites.google.com/site/appleclubfhs/support/advice-and-articles/lost-or-st olen
Oops! iForgot My New iPad On the Plane; Now What?
http://online.wsj.com/article/SB10001424052702303459004577362194012634000.html
If you don't know your lost/stolen iPad's serial number, use the instructions below. The S/N is also on the iPad's box.
How to Find Your iPad Serial Number
http://www.ipadastic.com/tutorials/how-to-find-your-ipad-serial-numberhttp://www.ipadastic.com/tutorials/how-to-find-your-ipad-serial-number
iOS: How to find the serial number, IMEI, MEID, CDN, and ICCID number
http://support.apple.com/kb/HT4061
Cheers, Tom -
Formatting text with GREP or find/change
Hi,
Is there a quick find/changesearch or a GREP that I can use to format all the text that is inside a pair of pipes? For example "|Gone with the Wind|" would then be italicized.
I have over a hundred pages of text that has been placed inside these pipes, and had Microsoft Word find/replace to format them, but can't seem to figure out how to do it in InDesign.
thanks in advance,
LinaIf the pipes are not to be deleted - in this case GREP is not the best way. Try nested style instead:
Have fun -
[SOLVED] Find all users with a MAILTO option in their crontab
Anyone know if this is possible? I have a script that lists all scheduled cronjobs but I need to find out which users have email notifications configured.
If anyone else wants it, here is the script I use to check all user's crontabs. I did not write this.. just found it a while back.
#!/bin/bash
# System-wide crontab file and cron job directory. Change these for your system.
CRONTAB='/etc/crontab'
CRONDIR='/etc/cron.d'
# Single tab character. Annoyingly necessary.
tab=$(echo -en "\t")
# Given a stream of crontab lines, exclude non-cron job lines, replace
# whitespace characters with a single space, and remove any spaces from the
# beginning of each line.
function clean_cron_lines() {
while read line ; do
echo "${line}" |
egrep --invert-match '^($|\s*#|\s*[[:alnum:]_]+=)' |
sed --regexp-extended "s/\s+/ /g" |
sed --regexp-extended "s/^ //"
done;
# Given a stream of cleaned crontab lines, echo any that don't include the
# run-parts command, and for those that do, show each job file in the run-parts
# directory as if it were scheduled explicitly.
function lookup_run_parts() {
while read line ; do
match=$(echo "${line}" | egrep -o 'run-parts (-{1,2}\S+ )*\S+')
if [[ -z "${match}" ]] ; then
echo "${line}"
else
cron_fields=$(echo "${line}" | cut -f1-6 -d' ')
cron_job_dir=$(echo "${match}" | awk '{print $NF}')
if [[ -d "${cron_job_dir}" ]] ; then
for cron_job_file in "${cron_job_dir}"/* ; do # */ <not a comment>
[[ -f "${cron_job_file}" ]] && echo "${cron_fields} ${cron_job_file}"
done
fi
fi
done;
# Temporary file for crontab lines.
temp=$(mktemp) || exit 1
# Add all of the jobs from the system-wide crontab file.
cat "${CRONTAB}" | clean_cron_lines | lookup_run_parts >"${temp}"
# Add all of the jobs from the system-wide cron directory.
cat "${CRONDIR}"/* | clean_cron_lines >>"${temp}" # */ <not a comment>
# Add each user's crontab (if it exists). Insert the user's name between the
# five time fields and the command.
while read user ; do
crontab -l -u "${user}" 2>/dev/null |
clean_cron_lines |
sed --regexp-extended "s/^((\S+ +){5})(.+)$/\1${user} \3/" >>"${temp}"
done < <(cut --fields=1 --delimiter=: /etc/passwd)
# Output the collected crontab lines. Replace the single spaces between the
# fields with tab characters, sort the lines by hour and minute, insert the
# header line, and format the results as a table.
cat "${temp}" |
sed --regexp-extended "s/^(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(.*)$/\1\t\2\t\3\t\4\t\5\t\6\t\7/" |
sort --numeric-sort --field-separator="${tab}" --key=2,1 |
sed "1i\mi\th\td\tm\tw\tuser\tcommand" |
column -s"${tab}" -t
rm --force "${temp}"
Last edited by thelastknowngod (2011-11-28 22:14:33)Perhaps I'm missing something here, but...
grep -i MAILTO /var/spool/cron/* -
[CS3 JS] How to search for accented letters with GREP
Hello,
In the following script I have two words, each that has an accented letter. It appears that neither in the script nor in the Find and Replace dialog that GREP will recognize words with accents. It will replace accented characters however. I can do a search for words with no accents but that will lead to trouble when I only want to change the word if it has an accent.
Any advice would be great!
Tom
var myDoc = app.activeDocument;
var rawWordsAccented = ["André","Barrës"]; //find these words
var rawWordsAccentedDHyphens = ["~-Andr\\x{00E9}","~-Barr\\x{00EB}s"]; //replacement words
for(var k =0; rawWordsAccented.length > k; k++){
var numWords = theGrepChanger(myDoc,rawWordsAccented[k],rawWordsAccentedDHyphens[k]);
}//end for k
function theGrepChanger(docRef,grepFindIt,grepChangeIt){
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = grepFindIt;
app.changeGrepPreferences.changeTo = grepChangeIt;
var arrGrepFindIt = myDoc.changeGrep();
return arrGrepFindIt;
}//end theGrepFinderJohn, perhaps it works in CS5 but not in CS3.
Peter, the problem is not in the replacement word or looping through that array backwards or forwards. The problem is finding a word with an accented character using the GREP mode.
In using the Find/Replace dialog I cannot find André. Nor Andr\x{00E9}, using Unicode. So if the dialog won't work it appears a script won't work. If I use "Andre" in the Search field it will find "Andre" and "André."
However I did find that if I change the GREP function in the script to the text mode I can find only words with accented characters and then replace them to my heart's content.
Tom
function theTextChanger(docRef,textFindIt,textChangeIt){
app.findTextPreferences = NothingEnum.NOTHING;
app.changeTextPreferences = NothingEnum.NOTHING;
app.findTextPreferences.findWhat = textFindIt;
app.changeTextPreferences.changeTo = textChangeIt;
var arrTextFindIt = myDoc.changeText();
return arrTextFindIt;
}//end theTextChanger -
Inserting a special character with GREP styles
Hi.
I wanna define a GREP style that makes this: if I write Bluetooth I wanna that a registered trademark is added at the end of the word but with superscript format. Is it possible?
Thanks in advance.No, GREP styles only apply formatting, they cannot insert characters. Use a regular find & change to do so.
(There is a thinking-outside-of-the-box solution. If you have access to a font creating utility, you can create a character 'h' with TM attached to it. Then you can use a GREP style to automatically apply this custom font to just the 'h' of 'Bluetooth'. See http://indesignsecrets.com/insert-a-special-character-with-grep-styles.php.) -
MS/UNIX/DB question - How to find MS characters in Unix scripts.
Hi. I apologise if this is a bit off-topic.
We have been developing sql scripts on PC's but need to run them from UNIX. We are find Microsoft characters like double spaces followed by a dash convert into little squares and upside down question marks. etc.
I can find them in the database using:
SELECT description_text, dump(description_text)
FROM descriptions
WHERE regexp_like( description_text, '[^[:print:][:space:]]');And get things like "Adjustment � Service".
In unix that might appear as "\266" in the middle of a text string. We find them in the db, fix them, and re-deploy.. but this is getting tiresome.
I want to be able to repeatedly scan all sql scripts in Unix, including files in subdirectories. (there are literally hundreds..)
We're running SunOS 5.10. I have tried "grep -r {266}" but the -r option isn't valid with my version of grep... :(
Any suggestions about the easiest/most pragmatic way of doing this?
Thanks in advance. :)
Pete
Edited by: peetmoore on 11-Aug-2009 19:51I couldn't get the shell script to work, so just kept playing with command line.
The closest I have is: find . -name "*.sql" | xargs grep 'xyz' Or using od: find . -name "*" | xargs | od -c | grep 'xyz' But i'm struggling a bit to identify and filter the specifc characters i'm looking for. They appear differently depending on how they're being viewed. (or not at all.) in some cases 2 spaces following by a dash " -" appeared as an update down question mark in Sql and "\266" in the unix script when viewed in vi. I don't have any current examples so it's hard to see what it looks like in od. -
Need some help with GREP expressions
I know--KNOW--there's a way to do this, but my GREP expressions keep failing.
I want to add an em dash before any phrase that's in a paragraph style. So I obviously want the em dash to be in the location "beginning of paragraph." All my GREP searches keep failing. Can someone help?Adobe's implementation of "beginning of paragraph" is a tiny bit off from standard GREP (which, in itself, is less a set of hard & fast rules, but more like "guidelines"). Yes -- you can search for beginning of paragraph using plain ^, but you cannot use it with a replace operation.
The trick is to give InDesign something to look for. Search for
^.
(that's right -- one wildcard right after the start of a paragraph). You don't want to loose the character it finds, so replace with
~_$0
where the first 2 codes is your em dash and the last 2 are "the entire found text". That's your original wildcard-found character!
Don't forget to put your paragraph style in the Find Formatting box.
This workaround works around the implementation failure, because you indeed want to add something to existing text. Unfortunately, another fairly standard GREP to look for empty paragraphs -- ^$ -- doesn't work, because then you have no place for a wildcard character ... (and yes, you can use a hard return \r instead of either first or last code, but then it won't work at beginning or end of story). It's one of those things I hope to see corrected with CS5.
[Edit] Ha! Peter beat me to it but he made a typo. Besides, my story is longer. -
Multiple text alignment in one story with GREP (or similar)
In search of trying to make my workflow much more efficient, I've been dabbling with grep styles and have come across an obstacle. This may be a limit to the character style features but I have been trying to find ways to use multiple text alignments (i.e. left, justified, right) within a single paragraph style sheet applied over multiple paragraphs. Is this actually possible with GREP or similar or do I just have my head in the clouds?
If this was actually possible in Character Styles, I could quite possible make my job a wee bit too easy!!
Hope you can assist me with this issue.
Cheers.Alignment is a paragraph level attribute, not a character level attribute, and therefor is assigned in the paragraph style. A paragraph can have only one alignment setting. GREP styles can only assign a character style, so cannot change alignment.
You could, however, use Find/Change with GREP to find a pattern and assign a pragraph style or new alignment, you just can't automate it the way you do with a GREP style.
Maybe you are looking for
-
Error while doing MR11 as enter Profitability segmet as Cost object
Hi All, While doing MR11, we noticed a error message (ZC - 001) as "Enter Profitability segment as Cost object for Revenue and COGS posting". The specified Material account is created as Cost element (CE Category 11) and in OKB9 configuration this co
-
I just bought an iPhone 4s yesterday and it wouldn't connect to the iTunes 10.6.3 I had already on my laptop for my husbands 3gs and my brother in laws iPhone 4. Neither of them ever had a problem syncing with itunes. When I tried I was told to unins
-
3014 error trying to update to 7.1.2 on iPhone 5c
Using Windows 7 Home Premium 64 bit Spent a huge amount of time doing the usual (restart computer, restart iPhone) and various other rabbit trails leading nowhere. I got an outstanding Apple chat representative on the phone. He convinced me to disab
-
One component is not exploding in CN21,while creating throgh VA01.
Hello Friends, Iam a PP Consultant and working on PS . my client having variant configuration.they create standard network cn01 and allocate the phantom assembly with materials say x and y in the activity 0080 . They created bom cs01 with dependen
-
How can I sort and summarize a flatfile
Hello, I have a question about sorting and summarizing in a file to Idoc scenario. The scenario is as follows. Flat file to Idoc conversion (invoic) Simple flat file structure (1 recordtype) Each record = 1 invoice item In a record are both header an